hilkeheremans / redux-persist-seamless-immutable

Use seamless-immutable with redux-persist v5
MIT License
50 stars 11 forks source link

TypeError: Cannot read property ‘merge’ of undefined #4

Closed pekq closed 6 years ago

pekq commented 6 years ago

At times the reconciler fails to merge and throws this error.
I was unable to pin point when exactly this happens or why. Presumably after larger state structure change.

Uncaught (in promise) TypeError: Cannot read property ‘merge’ of undefined
   at reconciler.js:34
   at Array.forEach (<anonymous>)
   at s (reconciler.js:16)
   at persistReducer.js:91
   at n (reduxsauce.js:229)
   at l (createStore.js:165)
   at middleware.js:71
   at index.js:48
   at Object.dispatch (middleware.js:66)
   at Object.l [as rehydrate] (persistStore.js:87)
   at persistReducer.js:57
(anonymous) @ reconciler.js:34
s @ reconciler.js:16
(anonymous) @ persistReducer.js:91
n @ reduxsauce.js:229
l @ createStore.js:165
(anonymous) @ middleware.js:71
(anonymous) @ index.js:48
(anonymous) @ middleware.js:66
l @ persistStore.js:87
(anonymous) @ persistReducer.js:57
Promise.then (async)
(anonymous) @ persistReducer.js:56
Promise.then (async)
(anonymous) @ persistReducer.js:52
n @ reduxsauce.js:229
l @ createStore.js:165
(anonymous) @ middleware.js:71
(anonymous) @ index.js:48
(anonymous) @ middleware.js:66
s.persist @ persistStore.js:96
o @ persistStore.js:99
t.a @ CreateStore.js:37
t.a @ index.js:47
(anonymous) @ App.js:14
t @ bootstrap abaa5d98ccee410482ed:19
(anonymous) @ main.b4c585ff.js:71680
t @ bootstrap abaa5d98ccee410482ed:19
(anonymous) @ main.b4c585ff.js:65389
t @ bootstrap abaa5d98ccee410482ed:19
(anonymous) @ bootstrap abaa5d98ccee410482ed:62
(anonymous) @ bootstrap abaa5d98ccee410482ed:62
hilkeheremans commented 6 years ago

That would be tricky to track down without some kind of view on what the persisted state was. Judging by your issue, I assume you can't reliably reproduce this?

pekq commented 6 years ago

I managed to reproduce this consistently by removing one of the slice reducers. Eg.

    export const reducers = persistCombineReducers(ReduxPersist.config, {
      router: routerReducer,
-     login: require('../Shared/Redux/LoginRedux').reducer
    })
tasos14 commented 6 years ago

Hi @pekq @hilkeheremans, i think that this error occurs because the reconciler tries to use merge at something that is not an object. We had the same problem at work.

hilkeheremans commented 6 years ago

Merged -- thanks for your contribution!

I have some docs to update, that will follow in the next few days.