-
Notifications
You must be signed in to change notification settings - Fork 634
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
HMR transform breaks React.forwardRef #272
Comments
I've also been experiencing this issue and after doing some digging I've figured out what is going on. In This option is later checked in
As you mentioned @haggholm, I'm not sure what the best fix is for this. A long term solution would likely be switching to the new React Hot Loader (https://github.com/gaearon/react-hot-loader) in Metro. Another solution would be to allow the |
Good point. I will likely give that a shot, although I would recommend https://www.npmjs.com/package/patch-package for the job. |
Ah, yes that's a better fix |
Hey, thanks for reporting and apologies for the delay answering. To give some context, some time ago we decided to enable the HMR transform always for development: this allows Metro to reuse the whole transformed bundle when switching HMR from the device, to not have to wait until the whole bundle gets retransformed (which can be quite slow for huge bundles). While we could revert that behaviour and make Metro only enable the HMR transform when HMR is on, this won't fix the root issue. Regarding a more long term solution, I'm supportive to start using /cc @gaearon |
Why can't we update it to support them? I'd be happy to release a fix if you send one.
It has the same issues as the existing solutions. Let's not do this. We have a better long term solution in mind. |
Using react-native 0.57.8, metro 0.48.5, react-redux v6 and redux-form v8 this issue has popped up for me. I'm using patch-package to fix it right now via: patch-package
--- a/node_modules/metro/src/Server.js
+++ b/node_modules/metro/src/Server.js
@@ -1067,7 +1067,7 @@ class Server {
dev,
minify,
excludeSource,
- hot: true,
+ hot: false,
runModule: this._getBoolOptionFromQuery(urlObj.query, "runModule", true),
inlineSourceMap: includeSource,
platform, |
Another solution without patching — #313 (comment) |
Again, if there’s a bug or missing thing in |
We've replaced the HMR transform with a different one that doesn't suffer from this issues. |
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
I originally filed this as gaearon/react-proxy#82, but the project does not look active (no updates in three years).
In short, if you use the new
forwardRef()
function on a component derived from (say)React.Component
, the result is not a component object butThis, then, causes an exception in
react-proxy
, which expects a prototype;react-proxy
is a dependency ofmetro
viareact-transform-hmr
.Curiously, it does not happen when the component passed to
forwardRef
derives an intermediate base class (itself derived fromReact.Component
), perhaps because it’s an ES6 class at transpile time?If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can
yarn install
andyarn test
.I do not currently have a minimal example. If needed, I can try to create one; I cannot share the code we have as it’s proprietary.
What is the expected behavior?
I would expect
forwardRef
to work regardless of whether I’m using the metro Babel preset or not.Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
Node v10.4.0
npm v6.1.0
metro v0.45.6
OS: Ubuntu 18.04
The text was updated successfully, but these errors were encountered: