rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.96k stars 865 forks source link

"either rehydrate or register is not a function on the PERSIST action" #743

Open Ashoat opened 6 years ago

Ashoat commented 6 years ago

Full error:

redux-persist: either rehydrate or register is not a function on the PERSIST action. This can happen if the action is being replayed. This is an unexplored use case, please open an issue and we will figure out a resolution.

This is occurring when I use the "import" function in Redux dev tools. It happens when I simply "export" the current state and then import it. It only occurs if the exported state includes the rehydrate action.

The reason I want this functionality is that I have set up some crash reporting logic that uploads the current Redux state to my server when the app crashes. I can then download a JSON file from my server that I can import into Redux dev tools to investigate the crash.

It's not the biggest deal, as I can avoid it by making sure the preloadedState is generated post-rehydrate, and the rehydrate action isn't included in the payload. But figured I'd make the issue since the error suggests it :)

leggomuhgreggo commented 6 years ago

@Ashoat encountering the same issue. Can you elaborate on the work around you mentioned? Thanks!

Ashoat commented 6 years ago

@leggomuhgreggo the short of it is that you just need to make sure the REHYDRATE action is not in your list of actions.

The JSON file you're importing has an object with a preloadedState property that has your Redux state at the "start", and a payload property that has a list of actions that get applied to get the Redux store to the "current" state. But preloadedState doesn't have to be the initial Redux state, and in practice the full list of actions can be prohibitively long.

The solution here is simply to make sure your list of actions doesn't include a REHYDRATE action. Have your preloadedState start after the REHYDRATE action. Here is how I do it.

m0o0scar commented 6 years ago

@Ashoat the "how I do it" link is 404. I believe you've moved the file to /lib/utils/redux-logger.js

samanshahmohamadi commented 4 years ago

I was using Redux DevTools and this solution did the trick for me: https://stackoverflow.com/a/52128658/3235344