packages/core: use useHistory in ErrorPage instead of passing via props

This commit is contained in:
Patrik Oldsberg
2020-05-14 15:14:24 +02:00
parent b16ad78bee
commit 299589040f
2 changed files with 4 additions and 9 deletions
@@ -23,11 +23,7 @@ describe('<ErrorPage/>', () => {
it('should render with status code, status message and go back link', () => {
const rendered = render(
wrapInThemedTestApp(
<ErrorPage
status="404"
statusMessage="PAGE NOT FOUND"
history={{ goBack: () => {} }}
/>,
<ErrorPage status="404" statusMessage="PAGE NOT FOUND" />,
),
);
rendered.getByText(/page not found/i);
@@ -19,13 +19,11 @@ import { Typography, Link, Grid } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { BackstageTheme } from '@backstage/theme';
import MicDrop from './MicDrop';
import { useHistory } from 'react-router';
interface IErrorPageProps {
status: string;
statusMessage: string;
history: {
goBack: () => void;
};
}
const useStyles = makeStyles<BackstageTheme>((theme) => ({
@@ -40,8 +38,9 @@ const useStyles = makeStyles<BackstageTheme>((theme) => ({
},
}));
const ErrorPage = ({ status, statusMessage, history }: IErrorPageProps) => {
const ErrorPage = ({ status, statusMessage }: IErrorPageProps) => {
const classes = useStyles();
const history = useHistory();
return (
<Grid container className={classes.container}>