目前,我的redux设置(使用Immutable.js进行状态设置)完全按需运行。然而,每当打开时,redux开发工具扩展都会输出以下错误:
减速器中出现错误类型错误:n.withMutations不是函数
就上下文而言,我使用redux-immutable作为其组合还原器函数,以组合我的反应路由器redux-reducer:
import { fromJS } from 'immutable';
import { LOCATION_CHANGE } from 'react-router-redux';
const initialState = fromJS({
locationBeforeTransitions: null,
});
export default (state = initialState, action) => {
if (action.type === LOCATION_CHANGE) {
return state.merge({
locationBeforeTransitions: action.payload,
});
}
return state;
};
以及我的商业逻辑减速器。
更新:构建带有webpack的生产捆绑包,在生产模式下测试应用程序(在docker容器中),并在开发模式下再次测试应用程序,(在没有docker的本地机器上)似乎已经解决了问题?古怪的
如果你想使用react-router-redux
,不需要实现你自己的reducer,只需从react-router-redux
导入routerReducer作为关键路由(重要),如下所示,并与其他Reducer、组合
import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
// Add the reducer to your store on the `routing` key
const store = createStore(
combineReducers({
...reducers,
routing: routerReducer
})
)
//To Sync navigation events with the store
const history = syncHistoryWithStore(browserHistory, store)
ReactDOM.render(
<Provider store={store}>
{ /* Tell the Router to use our enhanced history */ }
<Router history={history}>
<Route path="/" component={App}>
<Route path="foo" component={Foo}/>
<Route path="bar" component={Bar}/>
</Route>
</Router>
</Provider>,
document.getElementById('mount')
)
希望这就是您正在尝试实现的