Reputation: 769
I have a code that redirects to a default path if a certain flag is set. The redirected URL contains a variable id. I tried
return <Redirect to = {'/products/:id/details'}/>
and
return <Redirect to = {'/products/${id}/details'}/>
but neither of them will insert the id to the URL.
This is my code:
if (flag)
return <Redirect to = {'/products/:id/details'}/>
return(
//renders something
)
Upvotes: 0
Views: 411
Reputation: 12787
Just update like this with Template_literals
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals?retiredLocale=vi
return <Redirect to = {`/products/${id}/details`}/>
Upvotes: 1