1

Routes look like:

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

And inside of Landing I have a conditional Redirect that redirects to either buyer or seller which flows like:

<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 works. But, after I redirect, if I hit the back button it seems I have no history of having been at my "/" route. So my back button takes me to wherever I was before that.

What am I missing here?

colemars
  • 979
  • 3
  • 12
  • 25
  • Do you have a parent component `BrowserRouter` for your app? – Shashank Kadne Jul 21 '19 at 05:51
  • I do. My app is wrapped in in my index. – colemars Jul 21 '19 at 05:54
  • I missed the 'push' value for Redirect in the documentation. https://stackoverflow.com/questions/48731207/react-router-dom-and-redirect-not-being-added-to-history – colemars Jul 21 '19 at 06:02
  • Does this answer your question? [React-router-dom and Redirect not being added to history?](https://stackoverflow.com/questions/48731207/react-router-dom-and-redirect-not-being-added-to-history) – ecnepsnai Jul 24 '20 at 05:36

0 Answers0