-
Notifications
You must be signed in to change notification settings - Fork 791
Description
Description
Saving a file using hooks (specifically useState
) can sometimes unmount/remount the component. This only started happening after 4.12.0
Expected behavior
State should be preserved across hot reloads (which it did up to and including 4.12.0).
Actual behavior
State is reset since version 4.12.1
Environment
React Hot Loader version: 4.12.6
Run these commands in the project folder and fill in their results:
node -v
: v12.6.0npm -v
: 6.9.0
Then, specify:
- Operating system: macOS 10.14.5
- Browser and version: Chrome 75.0.3770.100
Reproducible Demo
https://github.com/dmarkow/react-hot-loader-hooks-issue
Run the start-working
script to launch with 4.12.0 which works fine. Run the start-broken
script to launch with 4.12.6 which is broken.
Change something inside the Counter.js
file (e.g. add some text to the "Counter: " output) and save. The first save it'll update the text and keep the counter running. However, save again without changing anything and it'll reset the counter and print the "Unmounting" message showing that the component got remounted.