Closed ashep closed 2 months ago
Hi there. I need to redirect from one route to another conditionally.
App:
App
export default class App extends React.Component { render(): JSX.Element { return ( <Router> <Home path={"/"} needSetup={true} /> <Settings path={"/settings"}/> </Router> ); } }
Home:
Home
export default class Home extends React.Component { componentWillMount() { if (this.props.needSetup) { console.log("redirecting..."); route("/settings", true); } } render(): JSX.Element { return ( <React.Fragment/> ); } }
I see the "redirecting..." output in the console, but no redirect is happening.
Thank you.
Looks like a bug, though I'd recommend switching to preact-iso. preact-router unfortunately hasn't been maintained.
preact-iso
preact-router
Thank you @rschristian!
Hi there. I need to redirect from one route to another conditionally.
App
:Home
:I see the "redirecting..." output in the console, but no redirect is happening.
Thank you.