mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Prevent reach/router Redirect Error Screen In Dev as a react til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
||||
|
||||
_740 TILs and counting..._
|
||||
_741 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -509,6 +509,7 @@ _740 TILs and counting..._
|
||||
- [Mapping Over One Or Many Children](react/mapping-over-one-or-many-children.md)
|
||||
- [Mock A Function That A Component Imports](react/mock-a-function-that-a-component-imports.md)
|
||||
- [Passing Props Down To React-Router Route](react/passing-props-down-to-react-router-route.md)
|
||||
- [Prevent reach/router Redirect Error Screen In Dev](react/prevent-reach-router-redirect-error-screen-in-dev.md)
|
||||
- [Proxy To An API Server In Development With CRA](react/proxy-to-an-api-server-in-development-with-cra.md)
|
||||
- [Quickly Search For A Component With React DevTools](react/quickly-search-for-a-component-with-react-devtools.md)
|
||||
- [@reach/router Renders To A Div](react/reach-router-renders-to-a-div.md)
|
||||
|
||||
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