我用的是redux和immutablejs。我们希望使用一个插件,它在内部使用redux,但不使用immutablejs。
import { fromJS } from 'immutable';
import { combineReducers } from 'redux-immutable';
import { LOCATION_CHANGE } from 'react-router-redux';
import { reducer as formReducer } from 'redux-form/immutable';
// prebuilt admin-on-rest features
import { adminReducer, localeReducer } from 'admin-on-rest';
// Initial routing state
const routeInitialState = fromJS({
location: null,
});
/**
* Merge route into the global application state
*/
function routeReducer(state = routeInitialState, action) {
switch (action.type) {
/* istanbul ignore next */
case LOCATION_CHANGE:
return state.merge({
location: action.payload,
});
default:
return state;
}
}
export default function createReducer(injectedReducers) {
return combineReducers({
route: routeReducer,
admin: adminReducer, // <==== This reducer is not immutable
// admin MUST be accessible using `(state) => state.admin`
// and NOT `(state) => state.get('admin')`
locale: localeReducer(),
form: formReducer,
...injectedReducers,
});
}我就是这样开这个店的:
const store = createStore(
createReducer(),
fromJS({}),
composeEnhancers(...enhancers)
);只有管理商店不应该是不变的。
是否有可能将管理插入该存储区,就像它在我们的不变表存储中一样?
发布于 2017-10-01 10:01:28
是的,您可以在一个不可变的对象(存储)中拥有普通的javascript对象/数组,但是在如何使用这个存储时,您需要小心。您将无法执行fromJS(store),因为这将使整个商店不可变。
https://stackoverflow.com/questions/46509928
复制相似问题