Javascript 如何在react router v4中通过props.history(路径、状态)传递函数

Javascript 如何在react router v4中通过props.history(路径、状态)传递函数,javascript,reactjs,react-router,Javascript,Reactjs,React Router,我在react项目中遇到问题,我正在做的是,在包含一些键和函数的状态传递对象上,通过包含两个参数的props.history,推送路径。当我在state对象中添加一个函数时,它会给我一个错误。有人能帮我摆脱这个问题吗 这是我的密码 const { history } = this.props; const data= { index: this.props.index, detail: this.props.object,

我在react项目中遇到问题,我正在做的是,在包含一些键和函数的状态传递对象上,通过包含两个参数的
props.history
,推送路径。当我在state对象中添加一个函数时,它会给我一个错误。有人能帮我摆脱这个问题吗

这是我的密码

const { history } = this.props;
        const data= {
           index: this.props.index,
           detail: this.props.object,
           handleSubmit: () => { console.log("i am not passing :(");}
        }
        history.push('/update-task/${index}', data);
以下是错误的屏幕截图:

注意:当我只传递简单对象和字符串值时,它工作正常,我得到的值类似于
props.location.state.key


上面的代码在react router v3上工作,但在react router dom中不工作。

错误是什么?@dfsq请检查错误是否非常清楚,您无法将函数传递到历史状态。@dfsq是否有任何方法将函数发送到其他组件?您可以通过道具将函数从父级传递到子级。