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
react-transform-hmr in RN 0.59 is causing problems with class static properties #26572
Comments
Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety? 👉 Click here if you want to take another look at the Bug Report issue template. |
Ok, I added the React Native version to the original post. React Native version:
|
It worked to remove the line |
@react-native-bot is that better? |
For anyone who finds this, I've come to the conclusion that it is OK to output ES5 since that is what Babel outputs as well, so I've just targeted ES5 and moved on. However, for future ES6+ support, it would be good to have a solution to this. |
same issue as well. But |
The bug in the latest RN(0.61.2) is fixed, hmr was replaced by |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
How do I prevent the hot module loader from wrapping my classes? And what is
react-transform-hmr
anyway. The NPM page says it's highly experimental. The NPM package hasn't been updated in 4 years, and the GitHub repo refers to a PR which was merged two years ago saying that it is deprecated in favor of the PR. Anyway, that's beside the point.Because of it I cannot call static methods from inside the class. The culprit appears to be this line, which comes between the class definition itself and the static assignments and creates a proxy that the methods inside the constructor cannot see changes to.
exports.ContentPage = ContentPage = _wrapComponent("ContentPage")(ContentPage);
It refers to this code inserted at the top of the module
I'm compiling my project from TypeScript to JavaScript using
react-native-transform-typescript
and then putting that into Babel. Source maps and everything else works fine, except that there must be something about the TypeScript class definition that is not quite syncing with Babel. I exported the source using the same settings, and the static properties are indeed assigned outside the class definition by TypeScript, however I don't think Babel should be interfering with this, because the developer might wish to do this as well.Here is my full tsconfig.json
If I change the target to es5, it works fine, of course, since the declaration is a function and therefore does not get wrapped. Anything later has the external property assignments (apparently Javascript does not use the static keyword), and therefore breaks.
I am using Expo, which uses react-native 0.59, but as best as I can tell it only uses
babel-preset-expo
which uses'metro-react-native-babel-preset'
for the most part.React Native version:
The text was updated successfully, but these errors were encountered: