我要塑造我的終極版店裏像這樣並添加searchForm的多個同胞:終極版減速器嵌套Redux的存儲屬性
import { Map } from 'immutable'
const searchForm = Map(
{
'categories': ['meat'],
'mealTypes': [],
'location': {
place: {},
distanceFromPlaceValue: 10,
distanceFromPlaceUnit: 'k'
},
'keywords': ''
}
)
const initialState = Map(
{
searchForm: searchForm
}
)
export default initialState
到目前爲止,我已經減速了categories
和searchForm的keywords
和正在創建的存儲這樣的:
const reducer = combineReducers({ keywords, categories })
const store = createStore(
reducer,
initialState,
devToolsEnhancer()
)
這給出了一個錯誤:
unexpected property "searchForm" found in previous state by the reducer...
CreateStore
需要採用與redux商店的頂級屬性相匹配的reducer。有沒有辦法將商店嵌入商店中,並且無錯地傳遞給減速器?或者我是否需要更改我的redux商店的形狀,並將任何減速器設置爲頂級商店屬性?
感謝這工作。我剛剛意識到我已經在使用'redux-immutable'中的'import {combineReducers} – user2602079