After updating from react-redux 5.0.2 to 5.0.3 hot reloading break the redux state.
hot reloading should not break redux state.
with react-redux 5.0.3 the redux state breaks after a hot reload has happened.
react-hot-loader 3.0.0-beta.6
Any project will do, just upgrade react-redux to 5.0.3 and experience the issue.
Can you confirm whether this breaks when you don't have React Hot Loader? From your description it sounds like it just breaks HMR for Redux state, not React components specifically.
@calesce For me it looks like the store becomes disconnected somehow - components don't break - actually after some more digging in 5.0.2 there is a weird effect that after the 1st hmr the state is still fine but after the 2nd hmr and then ongoing it becomes like a toggle where only every other state change is reflected by connected components. in 5.0.3 its completely broken/the components seem to be connected to a state that is not modified by actions anymore - or actions do not modify the state that is connected to the components.
There is a very simple demo repo you can find here.
I also noticed that hmr with react-hot-loader 3.0.0-beta.6 became a bit flaky/unreliable. So sometimes hmr just doesn't work until a full page reload and such things. But that might not be related to the react-redux problem which can reliably be reproduced.
Not sure if it's related, but I think the issue is not with react-redux but with react-hot-loader: tried with different options and the following happens:
[email protected], react-redux 5.0.3[email protected], react-redux 5.0.3Uncaught TypeError: Cannot read property 'shape' of undefined
at eval (eval at ./node_modules/react-redux/es/utils/PropTypes.js (main.js:5650), <anonymous>:7:73)
at Object../node_modules/react-redux/es/utils/PropTypes.js (main.js:5650)
at __webpack_require__ (main.js:660)
at fn (main.js:84)
at Object.eval (eval at ./node_modules/react-redux/es/components/Provider.js (main.js:5570), <anonymous>:3:75)
at eval (eval at ./node_modules/react-redux/es/components/Provider.js (main.js:5570), <anonymous>:73:30)
at Object../node_modules/react-redux/es/components/Provider.js (main.js:5570)
at __webpack_require__ (main.js:660)
at fn (main.js:84)
at eval (eval at ./node_modules/react-redux/es/index.js (main.js:5642), <anonymous>:1:79)
[email protected], react-redux 5.0.2Uncaught TypeError: Cannot read property 'shape' of undefined
at eval (eval at ./node_modules/react-redux/es/utils/storeShape.js (main.js:5666), <anonymous>:5:105)
at Object../node_modules/react-redux/es/utils/storeShape.js (main.js:5666)
at __webpack_require__ (main.js:660)
at fn (main.js:84)
at Object.eval (eval at ./node_modules/react-redux/es/components/Provider.js (main.js:5570), <anonymous>:4:76)
at eval (eval at ./node_modules/react-redux/es/components/Provider.js (main.js:5570), <anonymous>:75:30)
at Object../node_modules/react-redux/es/components/Provider.js (main.js:5570)
at __webpack_require__ (main.js:660)
at fn (main.js:84)
at eval (eval at ./node_modules/react-redux/es/index.js (main.js:5642), <anonymous>:1:79)
[email protected], react-redux 5.0.2I tried to debug the issue but only change I can think of is https://github.com/gaearon/react-hot-loader/issues/396 馃
For me, the problem was with react-redux. I was using version 5.05 of react-redux, went back to version 4.4.8 and it solved the issue. I'm not using react-hot-loader.
The project uses typescript. The @types/react-redux version refers to version 4, no idea if that could be affecting the compilation by somehow providing wrong types of the lib, as going back to version 4 solved the issue I did not try to remove @types/react-redux to test this hypothesis.
Seems fixed https://github.com/reactjs/react-redux/pull/715
Most helpful comment
Edit: Disregard most of this, it seems to have come back with beta.5 too
Not sure if it's related, but I think the issue is not with
react-reduxbut withreact-hot-loader: tried with different options and the following happens:[email protected], react-redux 5.0.3[email protected], react-redux 5.0.3[email protected], react-redux 5.0.2[email protected], react-redux 5.0.2I tried to debug the issue but only change I can think of is https://github.com/gaearon/react-hot-loader/issues/396 馃