Reactjs 从重定向发送道具到反应组件

Reactjs 从重定向发送道具到反应组件,reactjs,react-router,Reactjs,React Router,我有一个React组件,我在其中进行重定向 return <Redirect to={{ pathname: '/questions', state: { open: true } }}/>; 返回; 我需要在questions组件中访问此状态,我正在尝试使用返回undefined的this.state.location.open。我是缺少导入语句,还是完全错了?您尝试发送一些参数(可能不是最佳解决方案) 我认为在安装组件时,可以访

我有一个React组件,我在其中进行重定向

return <Redirect to={{
        pathname: '/questions',
        state: { open: true }
        }}/>;
返回;

我需要在questions组件中访问此状态,我正在尝试使用返回undefined的
this.state.location.open
。我是缺少导入语句,还是完全错了?

您尝试发送一些参数(可能不是最佳解决方案)


我认为在安装组件时,可以访问组件的状态。在这种情况下,您可能无法访问状态。我可能解释错了。我需要将一些状态从第一个组件传递到重定向到的组件。其中并没有一个是彼此的子组件,但有两个不同的路径。根据我所知道的答案,希望如此helps@Fripo ... 我也陷入了同样的境地。。。你找到解决办法了吗?
return <Redirect to={{
        pathname: '/questions/data_to_send',

        }}/>;
{
      path: 'questions/:data_to_receive',<---- HERE 
      getComponent(nextState, cb) {
        System.import('./containers/QuestionsComponent').then((m) => {
          cb(null, m.default)
        })
      }
}
this.props.routeParams.data_to_send