Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 浏览器后退按钮不是';t使用react router dom重定向后获取历史记录_Reactjs_React Router_React Router Dom - Fatal编程技术网

Reactjs 浏览器后退按钮不是';t使用react router dom重定向后获取历史记录

Reactjs 浏览器后退按钮不是';t使用react router dom重定向后获取历史记录,reactjs,react-router,react-router-dom,Reactjs,React Router,React Router Dom,路线看起来像: <Route path="/" exact component={Landing} /> <Route path="/Buyer" exact component={Buyer} /> <Route path="/Seller" exact component={Seller} /> 在Landing内部,我有一个条件重定向,重定向到买家或卖家,流程如下: <Button fluid onClick={thi

路线看起来像:

    <Route path="/" exact component={Landing} />
    <Route path="/Buyer" exact component={Buyer} />
    <Route path="/Seller" exact component={Seller} />

在Landing内部,我有一个条件重定向,重定向到买家或卖家,流程如下:

<Button fluid onClick={this.routeChange}>Seller</Button>

routeChange(e) {
   this.setState({navigateTo: `/${e.target.textContent}`})
}

if (this.state.navigateTo.length > 0) {
   return <Redirect to={this.state.navigateTo} />
}
卖方
路线更改(东){
this.setState({navigateTo:`/${e.target.textContent}`})
}
如果(this.state.navigateTo.length>0){
返回
}
这很有效。但是,在我重新定向后,如果我点击后退按钮,似乎我没有在我的“/”路线上的历史记录。所以我的后退按钮会带我去之前的任何地方


我在这里遗漏了什么?

您的应用程序是否有父组件
BrowserRouter
?我有。我的应用程序被包装在我的索引中。我在文档中错过了重定向的“推送”值。这回答了你的问题吗?您的应用程序是否有父组件
BrowserRouter
?我有。我的应用程序被包装在我的索引中。我在文档中错过了重定向的“推送”值。这回答了你的问题吗?