redux-persist: non-serializable value error
Hi folks đź‘‹,
I just installed the redux-persist in a project still in its early stages and I’m facing this error message in the console as first thing when the page loads. I haven’t done much besides including the lib as is, and my reducers are pretty simple for now, so I believe it has something to do with redux-persist itself?
Error:
index.js:1446 A non-serializable value was detected in an action, in the path: `register`. Value: Ć’ register(key) {
_pStore.dispatch({
type: _constants__WEBPACK_IMPORTED_MODULE_2__["REGISTER"],
key: key
});
}
Code above is followed by this message:
- Take a look at the logic that dispatched this action: {type: “persist/PERSIST”, register: ƒ, rehydrate: ƒ}…
- (See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)
SS of the whole thing:

Could anyone help me pointing me in the right direction? It does not break the application, but the error message is there in the console.
Cheers,
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 26
- Comments: 26
Commits related to this issue
- Store persistence using redux-persist. Note had to skip the serializable check in redux-toolkit for persisting, see: https://github.com/rt2zz/redux-persist/issues/988#issuecomment-552242978 — committed to raarts/expo-underpin by raarts 4 years ago
- fix: console error regarding redux persist We were getting a non-serializable value error logged to console. https://github.com/rt2zz/redux-persist/issues/988 — committed to grbull/lini by grbull 3 years ago
- fix: disable serializable action check for redux persist as mentioned in this issue: https://github.com/rt2zz/redux-persist/issues/988 — committed to Anapher/Strive by Anapher 3 years ago
- fix: disable serializable action check for redux persist as mentioned in this issue: https://github.com/rt2zz/redux-persist/issues/988 — committed to linuxteldev/adam-video-conferencing by linuxteldev 3 years ago
- fix: disable serializable action check for redux persist as mentioned in this issue: https://github.com/rt2zz/redux-persist/issues/988 — committed to srcppqtdev/video-conferencing by srcppqtdev 3 years ago
For anyone else struggling to find out what
[someReduxPersistActionType]should be, here’s myredux-starter-kit&redux-persistconfigThere’s a solution since redux-starter-kit@0.70
Now you can opt-out the serialization using
serializableCheckattr:We just added a section on this to the RTK Usage Guide page, here:
https://redux-toolkit.js.org/usage/usage-guide#use-with-redux-persist
Or, ignore a specific action type for the check:
@SeedyROM I removed the
getDefaultMiddlewarefrom the list of middlewares. There is no real fix there, it is a problem between opinions. Theserializable-state-invariant-middlewarecomplains when it sees a non-serializable object, a function in this case, being passed as an action;redux-persistneeds to do so. Sometimes you just have to pick a side 🤷‍♀️ .Anyway, here’s my
configureStore.for me this fixed the issue.
@rikinshah23 You need to configure the store as in my comment above
@SeedyROM I’m using them as they come, no custom config.
You might have to install those yourself, although I believe
redux-starter-kitwill have them already, I think it is better to have more atomic dependencies.About the PersistGate error you mentioned, I never saw this, I’m sorry. Also, don’t code while sleepy, man! hahaha
Are you using
redux-starter-kit? It looks like the message is caused by the includedserializable-state-invariant-middleware(https://redux-starter-kit.js.org/api/getdefaultmiddleware).As far as I can tell, passing the
registerandrehydratefunctions in the action is central to howredux-persistcurrently works, but the message can be suppressed by modifying the store configuration to not include that particular middleware function.getDefaultMiddleware() has now moved to @reduxjs/toolkit, and could be used by getting it in the argument of the callback function like this
export const store = configureStore({ reducer: persistedReducer, middleware: getDefaultMiddleware => getDefaultMiddleware({ serializableCheck: { ignoreActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER], }, }), });Same issue for me,
redux-persistis using default redux configuration andredux-starter-kitis waiting for a string.It would be nice to have a property into
configureStorelikepersist: trueinsideredux-starter-kitand handling this error by using the immer pattern fromredux-starter-kitty @rseemann
Are there any differences between these two?
because both works for me.
@aldreth Thanks I was able to solve the issue. I was directed to your solution and had help from @markerikson on a separate thread that I created.
@aldreth Thanks for the code 👍
I am using redux-persist with redux toolkit. here is my store configuration.
I haven’t implemented or configured store before. I intend to persist user state after login. Currently after login, if I reload app in emulator it always goes back to login screen.
is my store configured properly?
Here in index.js, I use PersistGate
quem ainda tiver o mesmo problema atualmente , eu resolvi desse jeito :
export const store = configureStore({ middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: false, }), redutor: { user: persistedReducer, }, });This should be added to
READMEhere regarding the compatibility betweenredux-persistandredux-toolkitandredux-starter-kit, becauseredux-toolkitandredux-starter-kitare pretty commonly used.That is exactly what is going on. Further investigating I noticed this in the default middleware. I’ll just remove the middleware, since it’s not really essential to what I’m doing.
Cheers!