do 404 modal redirect on unknown routes

This commit is contained in:
John Mitchell
2019-04-09 10:39:47 -04:00
parent 81267c7212
commit ad0e409448
3 changed files with 61 additions and 11 deletions

View File

@@ -0,0 +1,42 @@
import React, { Component } from 'react';
import { Redirect, withRouter } from 'react-router-dom';
import { Trans } from '@lingui/macro';
import { withRootDialog } from '../contexts/RootDialog';
class NotifyAndRedirect extends Component {
constructor (props) {
super(props);
const { setRootDialogMessage, location } = this.props;
setRootDialogMessage({
title: '404',
bodyText: (
<Trans>
Cannot find route
<strong>{` ${location.pathname}`}</strong>
.
</Trans>
),
variant: 'warning'
});
}
render () {
const { to, push, from, exact, strict, sensitive } = this.props;
return (
<Redirect
to={to}
push={push}
from={from}
exact={exact}
strict={strict}
sensitive={sensitive}
/>
);
}
}
export default withRootDialog(withRouter(NotifyAndRedirect));