Skip to content

Instantly share code, notes, and snippets.

@3nvi
Created June 5, 2020 15:17
Show Gist options
  • Save 3nvi/716e719cee2c91262a466ee465a83c92 to your computer and use it in GitHub Desktop.
Save 3nvi/716e719cee2c91262a466ee465a83c92 to your computer and use it in GitHub Desktop.
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