Converting 404 page to use hooks

This commit is contained in:
Jeff Avallone 2019-03-26 18:26:39 -04:00
parent 280412e2db
commit aa10ecf18c
2 changed files with 12 additions and 14 deletions

View File

@ -1,19 +1,18 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withTranslation, Trans } from 'react-i18next';
import { useTranslation, Trans } from 'react-i18next';
import Metadata from 'components/Metadata';
import Message from 'components/Message';
export const ErrorPage = ({ t }) => <>
export const ErrorPage = () => {
const { t } = useTranslation();
return <>
<Metadata title={ t('Page Not Found') } />
<Message type="error" heading={ t('404 Page Not Found') }>
<p><Trans>The page you have requested could not be found.</Trans></p>
</Message>
</>;
ErrorPage.propTypes = {
t: PropTypes.func.isRequired
</>;
};
export default withTranslation()(ErrorPage);
export default ErrorPage;

View File

@ -6,13 +6,12 @@ jest.mock('components/Message', () =>
import React from 'react';
import { render } from 'react-testing-library';
import { mockT } from 'i18n';
import { ErrorPage } from 'pages/404';
import ErrorPage from 'pages/404';
describe('Error Page', () => {
test('rendering', () => {
const { asFragment } = render(
<ErrorPage t={ mockT } />
<ErrorPage/>
);
expect(asFragment()).toMatchSnapshot();
});