rt2zz / redux-persist

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

redux-persist removing object methods after storing #1322

Open NitinMagdum opened 3 years ago

NitinMagdum commented 3 years ago

i am using redux-persist to store object which contains some properties and methods but when i read it it's removing the methods as it uses JSON.stringify before storing.

is there any configuration which will not do JSON.stringify or any other workaround

developer-collin commented 3 years ago

This doesn't exactly answer your question, but likely explains why redux-persist is not storing your object methods:

https://redux.js.org/style-guide/style-guide/#do-not-put-non-serializable-values-in-state-or-actions

Do Not Put Non-Serializable Values in State or Actions Avoid putting non-serializable values such as Promises, Symbols, Maps/Sets, functions, or class instances into the Redux store state or dispatched actions. This ensures that capabilities such as debugging via the Redux DevTools will work as expected. It also ensures that the UI will update as expected.