I already have my existing redux store setup was using the reducer from redux-form and react-router-redux, i want to migrate this to rematch, how can i do that.
Here is my code on setting up the store
import {routerReducer} from 'react-router-redux'
import {createStore, combineReducers, applyMiddleware, compose} from 'redux'
import thunk from 'redux-thunk'
import {reducer as reduxFormReducer} from 'redux-form'
export const setupReduxStore = (externalReducer = {}) => {
const defaultReducers = {
form: reduxFormReducer,
routing: routerReducer
}
const withExternalReducer = Object.assign({}, defaultReducers, externalReducer)
const reducers = combineReducers(withExternalReducer)
const enhancer = compose(
applyMiddleware(thunk), f => f,
)
return createStore(reducers, {}, enhancer)
}
Try this:
const store = init({
redux: {
reducers: {
...defaultReducers,
...externalReducers,
},
middlewares: [thunk],
}
})
:)
ah.. so it needs to be reducers, i was trying to use the combinedReducers as shown from the docs
init({
redux: {
combineReducers: customCombineReducers
}
})
it works now.. thanks
I see, that may be confusing.
combineReducers is meant for those that want to overwrite redux.combineReducers, for example, when using immutable.js.
If you could, could you put in a PR for the docs in a way that you feel is clearer to others? There is an easy way to edit and commit docs from Github using the "edit" option.
I'll do my fair share of contribution if i found the open source really helpful. As of now, i'm just exploring your idea and implementation if it's worth it to try. I have less knowledge also about this project so my contribution may not worth it or even cause harm than good.
But I really really find it interesting, thanks for sharing this!
Most helpful comment
Try this:
:)