Reputation: 4371
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?
Upvotes: 6
Views: 14416
Reputation: 4371
Resolved:
I had to wrap in curly braces like so:
<Redirect to={"/search/" + this.state.name} />
(Thanks to Giri for guidance)
Upvotes: 13