-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Include module.hot.accept in template or docs for HMR #4732
Comments
We are not going to advertise this as we suggest no one use HMR. It can lead to very difficult and hard to diagnose state bugs when used improperly. Thanks for the suggestion! |
Do you have an example? I've never had issues with it, and I actually find it much harder to troubleshoot style changes without HMR because of the FOUC. |
I had a bad experience with it. I ended up in a state where there is a compile error or something and I could never resolve the issue even after if I fixed the code (stopping the devserver and restarting didn't help). |
Style changes made in a |
So maybe make this feature optional? |
If HMR is that bad, why React Native supports it natively? |
Maybe there needs to be more of an effort to teach people how to properly clean up a module before it is swapped out for a new version. Maybe a better hot module API could aid in teaching people this. |
I was pleasantly surprised to learn that CRA has built in HMR support, and enabling it can be as simple as adding
module.hot && module.hot.accept()
to the end ofsrc/index.js
. I no longer have a flash of content when trying to compare style differences between renders, which is very helpful in development. While I'm happy with my current implementation, I wish it was more discoverable without prior Webpack HMR experience, as the feature is disabled by default and not mentioned in the user guide or readme.I propose adding
module.hot && module.hot.accept()
tosrc/index.js
so it can be modified or removed by users with more complex setups. Alternatively if we can't change the template, we can add an HMR section to the user guide to explain recommendations for a manual setup (assuming the user isn't ejecting) and make the feature more obvious, or at least mention the feature is supported by react-scripts in the readme.Note: It seems like #2304 is related but has a much wider scope. I'm interesting in a simple stopgap solution until we have that functionality built into react-scripts.
The text was updated successfully, but these errors were encountered: