You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often you redirect a route, as your application gets more complex and you require params and search on that route you find after hours of debugging that <Redirect /> strips everything away #4919. I propose a <Forward /> to explicitly say pass everything over, here's my current solution to this problem.
classForwardextendsReact.Component{forwardParams(to,computedMatch){constparamKeys=Object.keys(computedMatch.params);constreplacedParamsKeys=paramKeys.reduce((url,key)=>(url.replace(`:${key}`,computedMatch.params[key])),to);returnreplacedParamsKeys;}render(){const{ to, computedMatch, location, ...props}=this.props;return(<Redirectto={{state: {from: location},pathname: this.forwardParams(to,computedMatch),search: location.search,}}{...props}/>);}}
Example usecase redirecting a authentication callback
<Forwardfrom="/callback"to="/oauth/callback"/>
The text was updated successfully, but these errors were encountered:
Often you redirect a route, as your application gets more complex and you require
params
andsearch
on that route you find after hours of debugging that<Redirect />
strips everything away #4919. I propose a<Forward />
to explicitly say pass everything over, here's my current solution to this problem.Example usecase redirecting a authentication callback
The text was updated successfully, but these errors were encountered: