Hello,
I'm using redirectTo in my custom decorator
import React from 'react';
import { redirectTo } from '@reach/router';
export default WrapperComponent => class CheckPrivate extends WrapperComponent
{
componentDidMount()
{
if (WrapperComponent.private)
redirectTo('/auth');
super.componentDidMount();
}
}
This decorator i apply to my react component
import React, { Component } from 'react';
import CheckAuth from '~/utils/checkAuth';
@CheckAuth
export default class extends Component
{
static private = true;
static redirect = '/auth';
render()
{
return (
<h1>Hello</h1>
);
}
}
I have error: Uncaught (in promise) RedirectRequest { uri: '/auth' }
related to #91
I'll need a codesandbox to investigate further, will reopen if one is provided :)
Hey any update on this?
Same issue +1
@ryanflorence here is the issue in a codesandbox. Click on Dashboard to redirectTo Home and you will see the error logged in the console.
FWIW, navigate works as expected.
@bhanuka-diff @Rutulpatel7077 @joserocha3
I faced same issue, but I found that reach-router explicitly throw error if Redirect comopnent used,
so if you want to suppress the error, pass 'noThrow' props like below.
<Redirect noThrow={true} to="/foo/bar/baz"/>
@joserocha3 Thanks for the sandbox. I'll tackle this later this week unless anyone else calls dibs.
Unrelated to the issue, just a friendly reminder to those reviewing the sandbox to clean up their timeouts to avoid memory leaks 馃槃
const Dashboard = () => {
useEffect(() => {
const id = setTimeout(() => {
try {
redirectTo("/");
} catch (error) {
console.log(error);
}
}, 1000);
return () => clearInterval(id);
});
@bhanuka-diff @Rutulpatel7077 @joserocha3
I faced same issue, but I found that reach-router explicitly throw error if Redirect comopnent used,
so if you want to suppress the error, pass 'noThrow' props like below.<Redirect noThrow={true} to="/foo/bar/baz"/>
This didn't work when I tried it. Any other suggestions?
Hi! same issue with redirectTo(uri).
Any updates ? :(
Updates: navigate(uri) works for me! https://github.com/reach/router/issues/100#issuecomment-413114340
Most helpful comment
@bhanuka-diff @Rutulpatel7077 @joserocha3
I faced same issue, but I found that reach-router explicitly throw error if Redirect comopnent used,
so if you want to suppress the error, pass 'noThrow' props like below.