对于可能有相同问题的人,完整的解决方案是:
import {combineReducers} from 'redux-immutable'
import {fromJS} from 'immutable'
import { createStore, applyMiddleware } from 'redux';
import ThunkMiddleware from 'redux-thunk'
import {createLogger} from 'redux-logger'
const MyAppInitialState = fromJS({
Node1: {
entities: {},
ui: {}
},
Node2: {
entities: {},
ui: {}
},
Node3: {
entities: {},
ui: {}
},
Node4: {
entities: {},
ui: {}
}
})
const MyAppReducers = combineReducers({
Node1: Node1Reducer,
Node2: Node2Reducer,
Node3: Node3Reducer,
Node4: Node4Reducer
})
const LoggerMiddleware = createLogger()
const store = createStore(
MyAppReducers,
MyAppInitialState,
composeEnhancers(
applyMiddleware(
thunkMiddleware,
ApiMiddleware,
loggerMiddleware
)
)
)
// Example of a reducer (just for completeness)
const Node1Reducer = (state = fromJS({entities: {}, ui: {}}), action) => {
switch (action.type) {
...
default:
return state
}
}
使用此配置,我现在可以使用
Immutable.js
具有
Redux
拥有整个
state
作为
Immutable
树