Redux-persist: The example usage of "whitelist" and "blacklist" in docs causes confusion

Created on 22 Jan 2017  路  2Comments  路  Source: rt2zz/redux-persist

Here is what you guys currently have in the docs:

// config {}
{
  whitelist: ['reducerA'],
  blacklist: ['reducerB'],
  // ......
}

https://github.com/rt2zz/redux-persist/blob/master/docs/api.md

Then I went to redux's official documentation and here is what I found:

The reducer is a pure function that takes the previous state and an action, and returns the next state.
(previousState, action) => newState

http://redux.js.org/docs/basics/Reducers.html

So, if I understand correctly, reducers are functions that modify the state but not store itself nor the keys of the state. Then, I get really confused: what is "reducerA" and "reducerB" all about? Are those names of the reducers? In order to understand what is going on here, I went to the source code, and here is what I found:

stateIterator(state, (subState, key) => {
  if (!passWhitelistBlacklist(key)) return //<-- This line is the most important one
  if (stateGetter(lastState, key) === stateGetter(state, key)) return
  if (storesToProcess.indexOf(key) !== -1) return
  storesToProcess.push(key)
})

https://github.com/rt2zz/redux-persist/blob/master/src/createPersistor.js#L40

Again, if I understand correctly, it is checking the if the key in the state is whitelisted or blacklisted. It is not checking the reducers names.

I am aware of that many people are using combineReducers so the reducer name is equal to the key but still, they are not the same thing. So I suggest to update the docs and change all things like "reducerA" to "keyA".

stale

Most helpful comment

hm, agreed keyA is more semantically correct. Yes redux-persist assumes the state shape is a map of some kind, typically an object as output by combineReducers. I tried to write the docs in a way that will be friendly to new users. If this is causing confusion I am open to amending them but would appreciate feedback from others first.

All 2 comments

hm, agreed keyA is more semantically correct. Yes redux-persist assumes the state shape is a map of some kind, typically an object as output by combineReducers. I tried to write the docs in a way that will be friendly to new users. If this is causing confusion I am open to amending them but would appreciate feedback from others first.

This hasn't been responded to in a long while, so I'm going to mark it as stale. Please feel free to continue the conversation and I'll reopen.

@SCLeoX I'd appreciate if you submitted a PR helping improve the docs on this. I'd be happy to review it if there's a specific proposal to improve the docs.

Was this page helpful?
0 / 5 - 0 ratings