Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refering to static property's within static property's of a React Class gives error #373

Closed
jamaldewitte opened this issue Dec 8, 2017 · 3 comments
Labels

Comments

@jamaldewitte
Copy link

jamaldewitte commented Dec 8, 2017

Hi, upon using codesandbox I found the following issue:

Code:

class Example extends React.Component {
  static hello = "__hello__"
 static hi = Example.hello

render() {
return <div> Example </div> }
}

Expected: static hito be equal to '__hello__'
Result: _TypeError. Cannot read property 'hello' of undefined

Kind regards,

Jamal

@lbogdan
Copy link
Contributor

lbogdan commented May 8, 2018

Hey @jamaldewitte , thanks for your report, and sorry for the "small" delay! 🙂

So, this is an interesting one. I could trace it back to "Class properties work differently with transform-decorators-legacy", and it's caused by transform-decorators-legacy coming before transform-class-properties. That was changed in #154 to fix #151 , and it's also recommended by transform-decorators-legacy documentation. As the issue is still opened, I don't think we currently have a solution for this.

@CompuIves Any idea?

@CompuIves
Copy link
Member

This is a hard one. Our new template has one difference with CRA, which is that we support decorators. We released with this support and I realized this too late to remove it from the template. As I understand this is the cause of the error, having decorator support and class transform, right?

If that's the case there's not much that we can do currently except for waiting for either:

  1. Create React App v2
  2. A fix in the issue mentioned by @lbogdan

A third option would be to remove decorators from new, but this would break existing sandboxes relying on it.

@SaraVieira
Copy link
Contributor

This is now fixed in CRA v2

https://codesandbox.io/s/041q2oox20

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants