小编Jes*_*inz的帖子

react-redux:从减速器分派动作

我想从 BuildingComponent 的 reducer 函数分派一个动作来影响 InfoDrawer 的状态。

我知道这在 redux 中是不可能的,但我想不出替代方案。任何人都可以给我任何建议/推荐吗?

提前致谢。任何帮助表示赞赏。

建筑构件

//BuildingsState initial state
let initialState = {
  hasHighlight: false,
  buildings: [],
  visible: false,
}

// BuildingsState reducer
export function BuildingsState(state = initialState, action) {

  if (action.type === 'BUILDING_TOGGLE') {

    if(state.hasHighlight && state.visible) {

      // I WANT TO DISPATCH AN ACTION HERE
      // dispatch({ type: "ResetPOIs" })

    } else {
      return {
        ...state,
        visible: !state.visible
      }
    }
  }

  ...

}
Run Code Online (Sandbox Code Playgroud)

信息抽屉组件

//initial InfoDrawer State
const initialState = {
  open: …
Run Code Online (Sandbox Code Playgroud)

reactjs redux react-redux

1
推荐指数
1
解决办法
3966
查看次数

标签 统计

react-redux ×1

reactjs ×1

redux ×1