Git Product home page Git Product logo

Comments (7)

rt2zz avatar rt2zz commented on May 21, 2024 1

@IanVS yes that matters, autoRehydrate only looks at the first level of state. So in this case you have a few options:

  1. dont use autoRehydrate and have all of your reducers implement REHYDRATE
  2. have none of your sub reducer handle REHYDRATE (then autorehydrate will work as expected)
  3. write a custom version of autoRehydrate that does exactly what you need.

from redux-persist.

rt2zz avatar rt2zz commented on May 21, 2024

This is by design, autorehydrate checks for object equality.

Do you have a reducer that makes this behaivor problematic?

from redux-persist.

doxxx avatar doxxx commented on May 21, 2024

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.

rt2zz avatar rt2zz commented on May 21, 2024

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.

doxxx avatar doxxx commented on May 21, 2024

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.

IanVS avatar IanVS commented on May 21, 2024

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.

IanVS avatar IanVS commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.