Is there any way to redirect in component like in react-router?
MarcStdt opened this issue · 2 comments
MarcStdt commented
In react-router you can simply use to redirect in a component (not a route) to another route.
seems to work fairly different in found.
e.g. for react-router:
if (redirect) {
return <Redirect to="/example" />
}
return (
<Main>...</Main>);
Is such a thing also possible with found? I din't find any solution yet, but I am new to this library.
If there is no solution. Whats the best way to accomplish a similar behaviour?
taion commented
The best way to do this is to call router.replace
in a useEffect
hook, or something to that effect: https://github.com/4Catalyzer/found#programmatic-navigation
A redirect isn't really something that's renderable in any case - it's just an after-render effect/action that you do with the router.
MarcStdt commented
Thank you!