Closed sarink closed 8 years ago
I keep running into the error reducer is not a function.
reducer is not a function
Not sure what I'm doing wrong? My state is a plain object and some of the keys within state are Immutable
state
Immutable
redux/modules/rootReducer.js:
import { combineReducers } from 'redux-immutable'; import { routeReducer } from './routeReducer'; export default combineReducers({ routing: routeReducer, });
redux/modules/routeReducer.js:
import Immutable from 'immutable'; import { LOCATION_CHANGE } from 'react-router-redux'; const initialState = Immutable.fromJS({ locationBeforeTransitions: null }); const locationChangeReducer = (state, action) => { return Object.assign({}, state, {locationBeforeTransitions: action.payload}); }; export default function routeReducer(state = initialState, action) { switch (action.type) { case LOCATION_CHANGE: return locationChangeReducer(state, action); default: return state; } }
redux/createStore.js:
import { createStore as _createStore, applyMiddleware, compose } from 'redux'; import createMiddleware from './middleware/clientMiddleware'; import { routerMiddleware } from 'react-router-redux'; import reducer from './modules/reducer'; import { persistState } from 'redux-devtools'; import { DevTools } from 'containers'; export default function createStore(history, client, data) { // Sync dispatched route actions to the history const reduxRouterMiddleware = routerMiddleware(history); const middleware = [createMiddleware(client), reduxRouterMiddleware]; let finalCreateStore; if (_DEVELOPMENT__ && __CLIENT__ && __DEVTOOLS__) { finalCreateStore = compose( applyMiddleware(...middleware), window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument(), persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)) )(_createStore); } else { finalCreateStore = applyMiddleware(...middleware)(_createStore); } const store = finalCreateStore(reducer, data); if (__DEVELOPMENT__ && module.hot) { module.hot.accept('./modules/reducer', () => { store.replaceReducer(reducer); }); } return store; }
Duplicate of https://github.com/gajus/redux-immutable/issues/38
I keep running into the error
reducer is not a function
.Not sure what I'm doing wrong? My
state
is a plain object and some of the keys withinstate
areImmutable
redux/modules/rootReducer.js:
redux/modules/routeReducer.js:
redux/createStore.js: