Rematch: How to make it work with existing redux implementations

Created on 7 Mar 2018  路  4Comments  路  Source: rematch/rematch

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)

}

question

Most helpful comment

Try this:

const store = init({
  redux: {
    reducers: {
      ...defaultReducers,
      ...externalReducers,
    },
    middlewares: [thunk],
  }
})

:)

All 4 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ShMcK picture ShMcK  路  4Comments

ghost picture ghost  路  5Comments

haikyuu picture haikyuu  路  5Comments

saraivinha85 picture saraivinha85  路  6Comments

blairbodnar picture blairbodnar  路  3Comments