2016-04-30 85 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') 
) 

希望這是你正在努力實現的