Reactjs 对钩子做出反应,如何迁移由redux thunk触发的redux操作?

Reactjs 对钩子做出反应,如何迁移由redux thunk触发的redux操作?,reactjs,redux,react-hooks,Reactjs,Redux,React Hooks,动作代码与redux thunk配合使用 export const theAction=(param)=>(dispatch)=>{ 调度(某些动作(参数)); } 旧组件工作代码: 类MyComponent扩展组件{ ... render()=> } ... 导出默认连接(stateTrops,{theAction})(MyComponent); 新的挂钩,但未触发操作 功能MyComponent(道具){ 返回 } 我也尝试过(在黑暗中拍摄) 功能MyComponent(道具){ co

动作代码与redux thunk配合使用

export const theAction=(param)=>(dispatch)=>{
调度(某些动作(参数));
}
旧组件工作代码:

类MyComponent扩展组件{
...
render()=>
}
...
导出默认连接(stateTrops,{theAction})(MyComponent);
新的挂钩,但未触发
操作

功能MyComponent(道具){
返回
}
我也尝试过(在黑暗中拍摄)

功能MyComponent(道具){
const dispatch=usedpatch()
const theActionDispatch=()=>dispatch(theAction)
返回
}

如果很多孩子都有这个动作,我也会使用useCallback:

const theActionDispatch = React.useCallback(
  (...args) => dispatch(theAction(...args)),
  [dispatch]
);

Child
中,您如何调用
theAction
此.props.theAction
而不是
props.theAction
?(lol)
theAction
是否触发与
redux thunk
无关,因此请检查调用
theAction
的代码。
const theActionDispatch = React.useCallback(
  (...args) => dispatch(theAction(...args)),
  [dispatch]
);