Redux combineReducers,具有与儿童减速器相同级别的儿童属性

时间:2018-02-10 23:24:35

标签: javascript react-native redux react-redux

我想拥有这种形式的数据:

addPage

所以export const addPage = ( state: Map<*, *> = applicationState.get('addPage'), action: AddPageAction ): Map<*, *> => { switch (action.type) { case UPDATE_SHOP_LIST_DISPLAYED: { return state.set('shopListDisplayed', (action.payload: boolean)) } case UPDATE_RERENDER_KEY: { return state.set('rerenderKey', (!state.get('rerenderKey'): boolean)) } default: return state } } export const product = ( state: Map<*, *> = applicationState .get('addPage').get('product'), action: AddPageAction ): Map<*, *> => { switch (action.type) { case UPDATE_BRAND: { return state.set('brand', (action.payload: string)) } case UPDATE_NAME: { return state.set('name', (action.payload: string)) } case UPDATE_ITEM_TYPE: { return state.set('item', (action.payload: string)) } case UPDATE_DESCRIPTION: { return state.set('description', (action.payload: string)) } case UPDATE_PRODUCT_ID: { return state.set('id', (action.payload: number)) } case UPDATE_PRICE: { return state.set('price', (action.payload: number)) } case UPDATE_IMAGE: { return state.set('image', (action.payload: Image | any)) } case UPDATE_IMAGE_LINK: { return state.set('imageLink', (action.payload: string)) } default: return state } } export const shop = ( state: Map<*, *> = applicationState.get('addPage').get('shop'), action: Object ): any => { switch (action.type) { case UPDATE_SHOP_INPUT: { return state.set('shopInput', action.payload.shopInput) } case UPDATE_SHOP_PLACE: { return state.set('place', action.payload.place) } case UPDATE_SHOP_SHOULD_HIDE_RESULTS: { return state.set('shopShouldHideResults', action.payload) } case GET_SHOP_AUTOCOMPLETE_RESULTS_REJECTED: { console.log( 'there was an issue getting your autocomplete results: ', action.payload ) return state } case GET_SHOP_AUTOCOMPLETE_RESULTS_FULFILLED: { return state.set('shopAutocompleteResults', action.payload) } case GET_SHOP_PLACE_DETAILS_FULFILLED: { return state.set('place', action.payload.result) } case GET_SHOP_PLACE_DETAILS_REJECTED: { console.log('there was an issue getting place details: ', action.payload) return state } default: return state } } 有一个产品减速器和一个商店减速器以及它自己的减速器,仅用于它自己的两个属性“shopListDisplayed”和“rerenderKey”

我的减速机:

combineReducers

在这种情况下如何使用const rootReducer = combineReducers({ addPage: combineReducers({shop, product}), alertModal, categories, distanceSlider, editProduct, map, menu, searchPage: combineReducers({location}), searchPageFields: searchPageFields, searchResults, searchResultsPresenter

目前我有:

combineReducers

我认为我的shopListDisplayed: false,rerenderKey: false不会考虑addPage。我没有明确地将combineReducers reducer添加到addPage combineReducers中,该len(<groupby object>)处理.h的两个根属性。

我将其放入/(?:[^.].|\.[^h]|^.?)\.scss$/

我收到此错误:

  

意外的属性“shopListDisplayed”,“rerenderKey”中找到了   减速机收到的先前状态。预计会找到其中一个   已知的减速器属性名称:“shop”,“product”。意外   属性将被忽略。

0 个答案:

没有答案