Converting 404 page to use hooks
This commit is contained in:
parent
280412e2db
commit
aa10ecf18c
@ -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;
|
||||
|
@ -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();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user