rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.93k stars 866 forks source link

Auto rehydration on first level? #574

Open RaulTsc opened 6 years ago

RaulTsc commented 6 years ago

Hey guys

Great library, thanks for building it! This is more like a question than an issue probably.

So I am using redux-offline which in turn uses redux-persist to persist the state. But I am not 100% sure I understand how rehydration works. I initially thought that the REHYDRATE action gets dispatched so you can listen and hydrate any part of the state you want. But it looks like it also automatically replaces the state on the first level? Maybe it does some destructuring over the entire store with the persisted one?

This might leads to weird bugs i.e react-router-redux's property 'routing' being replaced and causing random redirects.

Thank you

rt2zz commented 6 years ago

redux-persist "shallow merges" 2 levels by default. This usually works pretty well as most redux apps use combineReducers, with each sub-reducer being a record with initial state. I would guess that for react-router-redux you would want to add that to the persist blacklist since router state is not something you typically want to persist (as it can be derived from the url instead).