Configuring sessionStorage persist state
See original GitHub issueI’m trying to figure out what I’ve been doing wrong for a while.
So, I implemented react-persist by passing the createStore the autoHydrate()
along with my middleware. And then tried to call it to persist into the sessionStorage like
persistStore(store, {
whitelist: ['locale', 'auth'],
storage: sessionStorage
});
trying to make only the locale and auth nodes of my state to persist into it. All I can get is the full state persisted into the localStorage instead …
What am I doing wrong?
On a side question … if I finally only make it so those two nodes are stored, should I just include the reducer entry looking for the REHYDRATE
action.type into the reducers actually using those nodes? Or is it even better to create a new reducer to be looking for this one and get all the payload in?
Thank you in advance
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
How to persist to both localStorage and sessionStorage at the ...
My first question is if my client side view and approach is correct or not. If it is, how can I update my...
Read more >Persisting Data with Redux, Thunk, Session Storage in React ...
In the above code, our LoginReducer by default receives two arguments namely state and action. The state is the current store state while...
Read more >Persist State | Elf | A Reactive Store with Magical Powers
The persistState() function gives you the ability to persist some of the app's state, by saving it to localStorage/sessionStorage or anything that implements ......
Read more >How to Persist React State in Local Storage - Felix Gerschau
Unlike localStorage , sessionStorage clears all data when the browser is closed. However, it does persist when the user refreshes the page or ......
Read more >Persist state with Redux Persist using Redux Toolkit in React
Setting up React; Persisting state with Redux Persist ... storage engines like sessionStorage and Redux Persist Cookie Storage Adapter.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, it is possible. I am using “redux-persist”: “^6.0.0”, and I can persist data in session storage by importing storage like this: import storage from ‘redux-persist/lib/storage/session’;
what if i want to make my storage dynamic like the default for some reducers and session for some reducers like auth ?