Comments (7)
@IanVS yes that matters, autoRehydrate only looks at the first level of state. So in this case you have a few options:
- dont use autoRehydrate and have all of your reducers implement REHYDRATE
- have none of your sub reducer handle REHYDRATE (then autorehydrate will work as expected)
- write a custom version of autoRehydrate that does exactly what you need.
from redux-persist.
This is by design, autorehydrate checks for object equality.
Do you have a reducer that makes this behaivor problematic?
from redux-persist.
I was able to fix my reducers that were causing the problem, but I filed
this in case it was unintended. Since it's by design, feel free to close it.
On Sat, 31 Oct 2015 at 14:38 Zack [email protected] wrote:
This is by design, autorehydrate checks for object equality.
Do you have a reducer that makes this behaivor problematic?
—
Reply to this email directly or view it on GitHub
#34 (comment).
from redux-persist.
I will leave this open for a bit to see if anyone else wants to weigh in.
The rationalization is, if the reducer handles the the REHYDRATE
action, it implies custom rehydration and based on this assumption autoRehydrate will skip that reducer. This also is nice because it prevents conflicts where autoRehydrate might overwrite something the reducer wanted.
from redux-persist.
Sounds reasonable to me.
On Tue, 3 Nov 2015 at 12:34 Zack [email protected] wrote:
I will leave this open for a bit to see if anyone else wants to weigh in.
The rationalization is, if the reducer handles the the REHYDRATE action,
it implies custom rehydration and based on this assumption autoRehydrate
will skip that reducer. This also is nice because it prevents conflicts
where autoRehydrate might overwrite something the reducer wanted.—
Reply to this email directly or view it on GitHub
#34 (comment).
from redux-persist.
If a nested reducer handles the REHYDRATE
action, is that entire reducer skipped? For example:
function subReducer1(state = initialState, action) {
switch (action.type) {
case 'ITEMS_UPDATED':
return {...state, items: actions.payload};
default:
return state;
}
function subReducer2(state = initialState, action) {
switch (action.type) {
case REHYDRATE:
return {...state}; // presumably something more complicated here
default:
return state;
}
const topReducer = combineReducers({
subReducer1,
subReducer2,
});
In the above example, will subReducer1
still be auto-rehydrated? In my testing so far, it does not seem to be.
from redux-persist.
Actually, in my case I have one more level of combineReducers
, so it's more like:
const topReducer = combineReducers({
anotherReducer,
midReducer: combineReducers({
subReducer1,
subReducer2,
});
});
Not sure if that makes any difference.
from redux-persist.
Related Issues (20)
- Deserialize key missing in config types
- A non-serializable value was detected in the state 😥 HOT 1
- 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
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.