Javascript 如何通过“重定向”中的道具传递函数;至;对象获取数据克隆错误

Javascript 如何通过“重定向”中的道具传递函数;至;对象获取数据克隆错误,javascript,reactjs,react-router,Javascript,Reactjs,React Router,可以将各种数据类型置于“to”JSON属性的状态部分,这是通过React Router v4通过重定向语句传递道具的方式,函数除外。它们会导致错误 我可以将函数作为自己的属性发送到“to”JSON的state部分之外,但在刷新时会导致错误,因为函数变得未定义 if (this.state.redirect) return <Redirect to={{ pathname:

可以将各种数据类型置于“to”JSON属性的状态部分,这是通过React Router v4通过重定向语句传递道具的方式,函数除外。它们会导致错误

我可以将函数作为自己的属性发送到“to”JSON的state部分之外,但在刷新时会导致错误,因为函数变得未定义

if (this.state.redirect)
                return <Redirect
                    to={{
                        pathname: "/sheets",
                        state: {
                            sandboxObj: this.sandboxObj,
                            // function is refreshUserSandboxes
                            refreshUserSandboxes: this.props.refreshUserSandboxes,
                        },

                    }} />;
if(this.state.redirect)
返回;
错误:

DataCloneError: Failed to execute 'replaceState' on 'History': function () {
            fetch(window.hostName + 'wali_rest/getUserSandboxes', {
                method: 'GET'...<omitted>... } could not be cloned.
DataCloneError:未能对“历史记录”执行“replaceState”:函数(){
fetch(window.hostName+'wali_rest/getUserSandboxes'{
无法克隆方法:“GET”…}。