2016-04-30 53 views
1

目前,我的redux设置(它利用Immutable.js的状态)完全按照需要运行。然而,终极版开发者工具扩展输出每当打开以下错误:Redux开发工具Chrome扩展Immutable.js导致错误

An error occurred in the reducer TypeError: n.withMutations is not a function

对于情况下,我使用redux-immutable其结合减速功能,好了,结合我反应过来,路由器Redux的减速机:

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; 
}; 

和我的业务逻辑reducer。

更新:构建生产包w/webpack,在生产模式下测试应用程序(在docker容器中)以及再次以开发模式(在本地机器上没有docker)测试应用程序似乎解决了问题?奇...

+1

这个问题是由下面的答案解决?你可以更新状态,或者在足够的情况下接受答案 – anoop

回答

1

如果你想使用react-router-redux,没有必要实施减速自己, 刚刚从react-router-redux如下导入routerReducer关键路由(重要的),并与其他减速器结合,

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') 
) 

希望这是你正在努力实现的