Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store doesn't have a valid reducer while using persistCombineReducers #516

Closed
therise3107 opened this issue Oct 29, 2017 · 3 comments
Closed

Comments

@therise3107
Copy link

therise3107 commented Oct 29, 2017

This is related to v5.
Error file
image

Store.js

import { persistStore, persistCombineReducers } from 'redux-persist'
import { createStore } from 'redux'
import storage from 'redux-persist/es/storage'
import reducers from './reducers'

const config = {
  key: 'root',
  storage,
}

const reducer = persistCombineReducers(config, reducers)

const configureStore = () => {
  const store = createStore(reducer)
  const persistor = persistStore(store)

  return { store, persistor }
}


export default configureStore

redcuers/index.js

import { combineReducers } from 'redux'

const initialReducer = (state = [], action) => return state

const reducers = combineReducers({
  initialReducer 
})

export default reducers

@rt2zz
Copy link
Owner

rt2zz commented Oct 29, 2017

perhaps the docs did not make this clear, but you should not need combineReducers that is handled by persistCombineReducers, so simply change reducers/index.js to be

import { combineReducers } from 'redux'

const initialReducer = (state = [], action) => return state

export default {
  initialReducer 
}

Open to suggestions for how to improve the docs around this.

@therise3107
Copy link
Author

Thank you @rt2zz. I'm closing this. Docs are fine just needs some more clarification on usage. I am just starting with redux-persist so I will gladly create PR's in coming days.

@Coder108
Copy link

@rt2zz What if I want to clear all the stored data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants