更新redux存储库属性中的根字段

时间:2018-03-07 16:52:19

标签: javascript react-native redux react-redux

我无法更新我的redux状态(shopListDisplayedrerenderKey)中的几个字段。顺便说一下,我使用状态的不可变js记录。

州:

enter image description here

我想更新addPage.shopListDisplayed。我不确定这种数据形状是否可行。代码使用正确的操作进入下面的reducer,并更正布尔值,但状态不会更新。

    export function createReducer(initialState, handlers) {
      return function reducer(state = initialState, action) {
        if (handlers.hasOwnProperty(action.type)) {
          return handlers[action.type](state, action)
        } else {
          return state
        }
      }
    }

    export const addPageReducer: Reducer<AddPageAction> = createReducer(
      applicationState.get('addPage') , {
        UPDATE_SHOP_LIST_DISPLAYED : updateShopListDisplayed
    })


    const updateShopListDisplayed = (state: ProductPage, action): ProductPage => {
      return state.set('shopListDisplayed', (action.payload: boolean))
    }


const rootReducer = combineReducers({
  addPage: combineReducers({
    shopInputControl: shopInputControlReducer, 
    product: productReducer,
    page: addPageReducer
  }),
  search: combineReducers({
    location: combineReducers({ autocomplete, location })
  }),
  alertModal,
  categories,
  editProduct,
  map,
  menu,
  searchResults,
  searchResultsPresenter
})

是否可以在我的redux商店中更新这两个字段?

0 个答案:

没有答案