我的初始状态是
export const initialState = fromJS({
current: {},
page: {
loading: false,
isFirstLoaded: false,
},
meta: {},
});
在我的化简器中,由于我为page
定义了嵌套结构,
state.setIn(['page', 'loading'], true);
工作正常。
由于我尚未为current
或meta
定义嵌套结构
state.setIn(['current', 'status'], 'done')
引发错误“无效的密钥路径”
当我记录状态时,
{
current: {..with properties including status is there as object..},
page: Map, // <--- why this alone being as Immutable Map,
meta: {}, // <--- This is also being as plain object
}
答案 0 :(得分:0)
根据以下文档,您应该可以使用mergeIn
方法:http://facebook.github.io/immutable-js/docs/#/Map/mergeIn。
希望有帮助!