Redux-persist: sub state for key `%s` modified, skipping myKey

Created on 1 Sep 2017  路  10Comments  路  Source: rt2zz/redux-persist

When my app is started I get the following message in console

sub state for key `%s` modified, skipping myKey

and so I don't see updated data for myKey. Can someone please advice what can be wrong?
Also, when my redux state for this key is updated I get no message that something gets written into storage.
Using react-native with AsyncStorage if it matters.

Most helpful comment

that means that your reducer for myKey is modifying state. Typically this is solve by making sure your default case for the reducer returns plain state
i.e.

default:
  return state

All 10 comments

that means that your reducer for myKey is modifying state. Typically this is solve by making sure your default case for the reducer returns plain state
i.e.

default:
  return state

Not sure if it's related or totally different issue. I'm getting this warning:

redux-persist/stateReconciler: sub state for key `_persist` modified, skipping.

See persistReducer.js L104-L111, it looks like state and inboundState has _persist key but reducedState doesn't. Is this intended?

@rt2zz thanks, changed my reducer and now all's working!

@leethree good catch, that dev check has now been updated to skip _persist key: https://github.com/rt2zz/redux-persist/blob/v5/src/stateReconciler.js#L60

@rt2zz awesome, thanks!

To add to this.... (since I was stuck on this forever):

If you're reducer uses

case default:
return {...state}

this will not work for redux-persist. Change it to return state;

I'm having this warning on v5 and the reducers already returns the state on case default.

redux-persist/stateReconciler: sub state for key `admin` modified, skipping.
redux-persist/stateReconciler: sub state for key `auth` modified, skipping.
redux-persist/stateReconciler: sub state for key `matches` modified, skipping.
redux-persist/stateReconciler: sub state for key `premium` modified, skipping.
redux-persist/stateReconciler: sub state for key `swipes` modified, skipping.
autoMergeLevel1.js:21

redux-persist/stateReconciler: rehydrated keys 'admin, albums, auth, deepLink, matches, permissions, premium, profiles, review, swipes, _persist'
autoMergeLevel1.js:29

It seems to be because I'm handling the REHYDRATE action type:

switch (action.type) {
  case REHYDRATE:
    return {
      ...initialState,
      ..._.omit((action.payload || {}).admin, ['loading']),
    }

Can this cause issue? What's the alternative implementation?

@cs1717c : Thanks man! that was exactly my problem.

@rt2zz thanks, it solves the very problem.

To add to this.... (since I was stuck on this forever):

If you're reducer uses

case default:
return {...state}

this will not work for redux-persist. Change it to return state;

Thanks, It saved my day

Was this page helpful?
0 / 5 - 0 ratings