mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Prevent reach/router Redirect Error Screen In Dev as a react til
This commit is contained in:
15
react/prevent-reach-router-redirect-error-screen-in-dev.md
Normal file
15
react/prevent-reach-router-redirect-error-screen-in-dev.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Prevent reach/router Redirect Error Screen In Dev
|
||||
|
||||
When using [@reach/router's
|
||||
`<Redirect>`](https://reach.tech/router/api/Redirect) with tools like
|
||||
create-react-app and Gatsby, you'll get those tools' development-mode error
|
||||
screen overlays whenever a redirect happens. This has to do with how
|
||||
@reach/router utilizes `componentDidCatch` to change the path without a
|
||||
render. That error screen overlay can get annoying though. Prevent it with
|
||||
the `noThrow` prop.
|
||||
|
||||
```javascript
|
||||
return (
|
||||
<Redirect to={anotherPath} noThrow />
|
||||
);
|
||||
```
|
||||
Reference in New Issue
Block a user