无法从reducer更新redux商店

时间:2018-04-24 20:47:34

标签: ecmascript-6 redux react-redux immutable.js

我似乎无法从reducer更新redux存储。状态是immutable.js记录,在图像中打印得很漂亮。

此减速器运行:

const searchResultsMapRegion = (state = vepo, action) => {
  switch (action.type) {
    case 'UPDATE_SEARCH_PAGE_RESULTS_PAGE_MAP_REGION': {
      console.log(state.toJS())
      const newState = state.set('some', 555)
      console.log(newState.toJS())
      return newState
    }
    default:
      return state
  }
}

const rootReducer = combineReducers({
  product: product,
  searchResultsMapRegion: searchResultsMapRegion
})

export const rootEpic = combineEpics(
  fetchCategoriesEpic,
  getUserPositionEpic,
  getUserLocationEpic,
  getUserLocationFulfilledEpic
)

export const store = createStore(
  rootReducer,
  vepo,
  composeWithDevTools(applyMiddleware(createEpicMiddleware(rootEpic)))
)

我有其他减速器作用于该州的product部分并且它们工作正常。为什么我不能在问题中显示的州some部分采取行动?

减速器顶部的state的console.log:

enter image description here

在reducer中的newState的console.log enter image description here

减速器完成运行后,

state的console.log:

enter image description here

1 个答案:

答案 0 :(得分:0)

重新检查案例类型。这是指正确的案例值吗?此外,需要从createStore中删除vepo。

export const store = createStore(
  rootReducer,
  vepo,
  composeWithDevTools(applyMiddleware(createEpicMiddleware(rootEpic)))
)