2016-08-12 107 views
1

根據我的閱讀,這應該不成問題(redux是v3.3)?我究竟做錯了什麼?combineReader將不可變映射轉換爲純JS對象

rootReducer.js

import { combineReducers } from 'redux'; 
import { routeReducer } from 'react-router-redux'; 
import { reducer as reduxAsyncConnectReducer } from 'redux-async-connect'; 
import myReducer from './modules/myReducer'; 

export default combineReducers({ 
    routeReducer, 
    reduxAsyncConnectReducer, 
    myReducer, 
}); 


myReducer.js

import { Map } from 'immutable'; 

const initialState = Map({}); 

export default (state = initialState, action = {}) => { 
    switch (action.type) { 
    default: 
     // On the third run "@@INIT" the state gets converted from a Map to a plain JS object :(
     console.log('action:', action.type, 'state:', state); 
     return state; 
    } 
}; 


輸出

action: @@redux/INIT 
state: Map {size: 0, _root: undefined, __ownerID: undefined, __hash: undefined, __altered: false} 

action: @@redux/PROBE_UNKNOWN_ACTION_x.5.a.b.w.u.f.k.8.3.q.b.s.5.e.e.4.5.c.d.i 
state: Map {size: 0, _root: undefined, __ownerID: undefined, __hash: undefined, __altered: false} 

action: @@INIT 
state: Object {} 

回答

相關問題