1
0
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:
jbranchaud
2019-01-24 19:01:05 -06:00
parent 4df88cec0a
commit d0e6000c4f
2 changed files with 17 additions and 1 deletions

View 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 />
);
```