-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[0.18.0-rc] class properties now needs a semicolon but packager throws a cryptic error #5188
Comments
Hey gre, thanks for reporting this issue! React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
|
I think you need a semicolon after the arrow function, babel changed this in 6.4.0
From my looking around last night, there is no plugin that removes this check |
babel/babel#3225 Is breaking everyone's RN apps if they re-install node modules. I sort of agree with their reasoning for the breaking change but it is annoying that it is transparently upgraded if the react-native module is reinstalled without even upgrading RN itself. |
@benjreinhart what do you mean "if they re-install node modules" ? is there a cache somewhere? Because i've |
Yeah.. that's why you're getting the error. When you reinstall the So the fact that it is throwing errors isn't a bug. It was a bug that that code worked in the first place, at least according to the pull request I linked to above. |
I can confirm this in 0.18-rc. I noticed the same error as @gre: I don't have a problem with babel's behavior here (I don't care if I have to put semicolons after class properties) but the cryptic error that the transformer throws in 0.18-rc should be classified as a bug. It gives no help in solving the problem. |
@benjreinhart oh yeah I see. Thanks @toadums for pointing the error cause, this is going to be a pain for everyone using this feature as the error message is totally not straightforward, but hopefully when people will search for this they might fall here. |
@gre I would leave this open; packager should report the babel failure so that users can find and fix the class-properties bug in their code. This is the behavior in 0.17. I think this is a regression in packager. |
@corbt sorry I thought you meant it was a bug in babel, opened :) |
@gre There's no official migration tool but I made a PR for JSCS to add autofix for class properties for the requireSemicolons rule real quick for this. babel/babel#3225 (comment). I'l try to get a new version out later today, otherwise follow the steps I mention. Also we will add a deprecation message next time. |
@satya164 , i've updated the title and added a better description, would that work? |
@gre The issue with Packager is not specific to class properties, is it? Does it show errors for other kinds of babel issues? |
@satya164 good question. I don't know that's the only error I had so far. if not, probably open a new generic issue as you said |
@satya164, I found it occurring for two related babel issues: class A {
static propTypes = {
style: React.PropTypes.object,
} // need a semicolon here
onChange = () => {
} // need a semicolon here
} Here is a discussion about the change: es-class-fields-and-static-properties. I found jeffmo's explanation helpful. |
@toadums Both of these are class properties though. |
Fair enough, those are just the two syntax' that I had the error occur on :) |
I had the same issue today, transpiling with webpack and babel. This is a 'spec compliancy' update in babylon babel/babel#3231 (diff) but breaks all arrow functions in a class. My solution eventually was to just refactor to normal functions, and bind 'this' where necessary. will post at the normal React git as well, found this one on google. Babel could have blogged this. |
You just need to add semi-colons. No need to change them to function and bind this manually. |
EDIT: discussion of packager error continues in #5191. Ok, I've had a chance to install the RC and take a look at this again. It looks like the packager isn't passing through any babel errors. Example errors from removing the closing bracket of a function: React Native 0.17
React Native 0.18-rc
|
@corbt thanks :) let's close this and focus on your generic issue |
Since this morning I'm having this issue again, anybody else?
class LoginModal extends React.Component {
static propTypes = {
error: PropTypes.string,
isLoading: PropTypes.bool.isRequired,
login: PropTypes.func.isRequired,
} // <-- needs semicolon now My .babelrc:
P.S.: The repo is here |
This shouldn't be an issue anymore since the change was reverted a while back in 6.5.2 https://github.com/babel/babel/releases/tag/v6.5.2 - I would probably clear/reinstall node_modules? |
I already tried with:
Thank you anyway hzoo, I also asked on stackoverflow, because it seems it's an issue only on my setup and/or is better discussing it there. |
It is so weird, I can confirm I'm still having the issue, tried with both React-Native 0.20 and 0.21 on two different projects (on both Ubuntu and OSX). |
Fixed on 0.22.0-rc, 0.21.0 was using babel < 6.5.2 |
this used to work, but now in
0.18.0-rc
TransformError: .../index.js: Cannot read property 'error' of null
Do we need to explicitely add some babel plugin now for this? or is it a bug?
answer is you must use a semicolon now, so:
But the error is not straightforward, this shouldn't break like this in packager
The text was updated successfully, but these errors were encountered: