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
Component wrapped in reduxForm gets unmounted on HMR #3005
Comments
Hi @butchyyyy! Thanks for your report. #623 is the most popular one, but I think you have provided the most useful information so far - I'll close those issues and point them here. |
There apparently already was a fix for this which is now removed in master, does anyone know why? See here |
That was imho more of a workaround than fix, you can do that via form configuration like this:
Problem i see with this is that the app wil behave differently in prod / dev mode. While it "fixes" the problem of loosing data on hot module replacement, it introduces another problem of data not being destroyed when you unmount the component by e.g. navigating to another view => you have to somehow handle form reset in dev mode when you navigate back. |
Yes, of course, but i'd like to avoid doing that for my forms. But i also understand that it's a workaround. There seems to be no easy way of solving this. How did it work with hmre? Do you know why is |
Very likely that this is the reason: gaearon/react-hot-loader#304 |
If I use destroyOnUnmount the value will stay the same, but I can no longer edit the input value. :( |
There is a bug in the react-redux lib which caused my problem: gaearon/react-hot-loader#492. Going back to 4.4.6 fixed my problem, now I am going to try react-redux again. |
As I see redux-form uses react-redux 5.0.4 which might have the same bug. |
For me, using the deprecated |
Hey guys, is there an update on this issue? |
Fix published in |
@erikras Hello, I've updated to 7.1.2 version and it seems like component with redux-form wrapper still unmounted. Could you send a link to working example? Thank you |
Still have the issue with latest redux form. |
Hi, I'm also still having this issue, is there some configs we need to change? |
@erikras Is there any planned fix for this? |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hello, i'm working on new react + redux + typescript + webpack2 starter kit. I'm using the react-hot-loader 3 beta for HMR which works fine... all my components that do not use redux-form get hot replaced without reloading the module or unmounting the component from DOM.
Once i wrap the component in reduxForm to sync form state into the redux, unfortunately my component stops hot reloading correcly - every hot update unmounts and mounts component to the DOM.
What is the current behavior?
HMR unmounts component wrapped in reduxForm
What is the expected behavior?
HMR should not unmount component
Sandbox Link
I've created a branch of my project where you can reproduce the issue:
git clone -b hmr-repro https://github.com/butchyyyy/arbes_react_poc
yarn install
yarn start
open https://localhost:8080
Make a change to the BankAcountContainer.tsx => Hot update performed without unmounting the component
Click "Add Payment Order" button next to the bank account, fill some value into the form and make a change to AddPaymentOrderContainer.tsx => Hot update performed with unmounting and mounting back the component emmiting destroy and loosing the from state in redux store.
What's your environment?
Library versions: https://github.com/butchyyyy/arbes_react_poc/blob/hmr-repro/package.json
Node 6.10.3
Windows 8.1 Pro
Google chrome: 58.0.3029.110 (64-bit)
Other information
I've tried various changes to my setup, but the problem was still there.
Unfortunately this is beyond my js knowledge so i don't know if it's redux-form, react-hot-loader or webpack problem, but the HMR works fine for everything but components wrapped in redux-form
I've tried to isolate the issue and in found out that in react-dom/lib/shouldUpdateReactComponent.js, at the line
return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
this comparision returns false
prevElement.type === nextElement.type
The text was updated successfully, but these errors were encountered: