edy / redux-persist-transform-filter

Filter transformator for redux-persist
MIT License
190 stars 21 forks source link

documentation: transforms inside persistReducer instead of persistStore #22

Open FibreFoX opened 6 years ago

FibreFoX commented 6 years ago

Current documentation inside README.md contains the following example code:

persistStore(store, {
  transforms: [
    saveSubsetFilter,
    saveSubsetBlacklistFilter,
    loadSubsetFilter,
    saveAndloadSubsetFilter,
  ]
});

Using this with redux-persist in version 5.9.1 results in thrown error-message: redux-persist: invalid option passed to persistStore: "transforms". You may be incorrectly passing persistConfig into persistStore, whereas it should be passed into persistReducer.

Please update usage-example to something like this:

// "loading"-attribute should not be loaded from store
const loadPartialLoginFilter = createFilter(
    'login',
    null,
    ['loading'],
    'blacklist'
);

// prepare persist configuration
const persistConfig = {
    key: 'root',
    storage,
    whitelist: ['settings', 'login'],
    transforms: [
        loadPartialLoginFilter
    ]
};

const persistedReducer = persistReducer(persistConfig, reducers);

const store = createStore(
    persistedReducer,
    {},
    composeEnhancers(applyMiddleware(ReduxThunk, createLogicMiddleware(logics, deps)))
);

// "transforms" is not applied here
export const persistor = persistStore(store);
ifeoluwak commented 6 years ago

This issue still hasn't been fixed