Created
June 5, 2020 15:17
-
-
Save 3nvi/716e719cee2c91262a466ee465a83c92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useLocation } from 'react-router-dom'; | |
import { get } from 'lodash'; | |
import Page404 from './Page404'; | |
const ErrorHandler = ({ children }) => { | |
const location = useLocation(); | |
switch (get(location.state, 'errorStatusCode')) { | |
case 404: | |
return <Page404 />; | |
// ... cases for other types of errors | |
default: | |
return children | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment