Comments (6)
What do you currently use rehydrateAction for? The recommendation is currently to do any custom rehydration processing in your reducer, or if you need to do async validation in a saga.
It was removed because in an attempt to keep the overall api and complexity limited. If you have a use case that cannot be satisfactorily handled elsewise, I would be happy to readd support.
from redux-persist.
also fwiw in the short term you should probably stick to 1.5.3 until we have time to think over how this fits into 2.0
from redux-persist.
The use case that came to mind was triggering a refresh of an authentication token if the prior had expired.
from redux-persist.
I did end up just keeping our dependency at 1.5.3. The addition of the rehydrateAction
to handle this scenario has the odd effect of persist/COMPLETE
firing before the persist/REHYDRATE
events, though :)
I'm rather unfamiliar with how sagas work (or what they are, in this context), but I'll do some digging. It's clear that some rearranging needs to be done.
from redux-persist.
Ah, ok refreshing/expiring auth tokens is exactly why I added rehydrateAction in the first place! Since then however we changed how we handle auth tokens.
My recommendation is you do auth token validation in the persistStore callback:
persistStore(store, config, (err, state) => {
if(state.auth.token) processToken(state.auth.token)
})
Thoughts?
from redux-persist.
That makes sense to me. I'm thinking I'm going to pull the whole auth flow out into a middleware, actually. There I can schedule the next token refresh and so on in a reasonable manner.
Thanks for all your help!
from redux-persist.
Related Issues (20)
- Do you support persist bigint when serialize? HOT 3
- Importing PersistGate results in compilation error HOT 1
- Jest snapshot is always created as null in react native
- Persist not working after page reload or refresh HOT 3
- failed to preserved initial state value at rehydrate
- PersistGate in SSR applications rendering app twice when using React v18 HOT 3
- Documentation for Migration is unnecessary complicated. HOT 1
- Getting got unexpected undefined error while changing redux state HOT 1
- getting error: A non-serializable value was detected in an action HOT 5
- createStore() is old
- Clear Redux Persist Data on App uninstall in IOS React Native HOT 1
- Support for Redux v5 and RTK v2 HOT 10
- state is null HOT 1
- data migration security and automatization
- Redux persist not working with RN 0.73 HOT 10
- Move project to new repo? HOT 13
- redux-persist failed to create sync storage. falling back to noop storage | Next js HOT 3
- Vitest - The slice reducer for key "reducer name" returned undefined during initialization
- Option to disable storage creation error for dynamic stores
- storage.getItem is not a function (it is undefined) - RN 0.73.4 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-persist.