【问题标题】:react native Redux:Even though I have used useDispatch I still do not have access to methods in the actionreact native Redux:即使我使用过 useDispatch 我仍然无法访问操作中的方法
【发布时间】:2021-03-17 14:12:03
【问题描述】:

我在我的组件中使用了调度,如下所示,但我收到错误 modifySeatMap is not defined 。但我确实在我的一个操作文件中定义了 modifySeatMap 函数。为什么这显示 modifySeatMap 尚未定义? 常量调度 = useDispatch();

  const changeStatus=(seat)=>{
    console.log("change status called with seat",seat)
    seat.status="selected"
dispatch(
  modifySeatMap(props.seatMap))
  }

我在这里附上目录结构的屏幕截图和操作中的方法

这里为什么没有定义 modifySeatMap?

【问题讨论】:

    标签: react-native redux react-redux


    【解决方案1】:

    从您的代码中,我没有发现任何问题。

    我认为问题在于您如何应用中间件。

    它应该看起来像这样。

    export default store = createStore(rootReducer, applyMiddleware(thunk))
    

    【讨论】:

      猜你喜欢
      • 2018-06-02
      • 2019-12-09
      • 2020-05-03
      • 2022-08-14
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多