question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autoRehydrate does not lift the reducer it makes

See original GitHub issue

Finally found the root cause…

Problem: if you use redux-devtools & call replaceReducer, the initial state overrides the persisted state.

Reason: replaceReducer doesn’t know about the reducerEnhancer that autoRehydrate() creates. That means the devtools inits without it, and doesn’t merge the initial state with the persisted state.

Reproduction: Call store.replaceReducer on an async route. (Probably works on sync routes, too. Haven’t tried).

Workarounds: None (use redux-storage?)

Fix: Either offer a reducerEnhancer like redux-storage or lift the replaceReducer into the liftedStore. I think the former is cleaner because autoRehydrate does not need a lifted store, so using a higher-level API seems reasonable.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rt2zzcommented, Nov 18, 2016

the latest version now lifts the reducer. I am using it in a HMR environment and it works. If there are outstanding issues please reopen!

1reaction
rt2zzcommented, Jul 19, 2016

@mattkrick thanks for the reference now i understand what you mean by lifted reducer 😃

I believe we can classify this as a bug, and fix by lifting the reducer in v3. For v4 I will reconsider the higher order reducer option.

redux-storage is a great choice as well, I am glad that worked out. Redux persist does a lot to be performant out of the box, hopefully after we get all of this sorted you can give it another try 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the use of autoRehydrate in redux-persist and why it ...
autoRehydrate means calling for the persist/REHYDRATE action to read the persisted state from the disk (which you have persisted before) ...
Read more >
redux-persist - npm
Auto rehydrate is a higher order reducer that automatically rehydrates state. While auto rehydration works out of the box, individual reducers ...
Read more >
vovkasm/redux-persist v4.10.1 - npm.io
autoRehydrate is a store enhancer that automatically rehydrates state. While auto rehydration works out of the box, individual reducers can opt in to...
Read more >
[Solved]-Adding style attribute in react-Reactjs
There is a logic error in your example code. The css are not updated, only the text. So use the ternary to change...
Read more >
Redux Persist Blacklist Deleting Reducers? - ADocLib
Hi I was trying to make only one reducer persist like in my code below: I've got a react redux app and using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found