I have a route set up:
<Route path="/search/:name" component={foo} />
In a component I am trying to redirect based on the entered name:
<Redirect to="/search" />
I want to pass this.state.name to the Redirect, like /search/name. How?
Resolved:
I had to wrap in curly braces like so:
<Redirect to={"/search/" + this.state.name} />
(Thanks to Giri for guidance)
this.state.nameis available in the scope, you can simply write<Redirect to={`/search/${this.state.name}`} />