fix(react): add missing react memory router

This commit is contained in:
Ely Lucas
2020-01-13 09:08:34 -07:00
parent d294e67f52
commit 57eec1cb0a
3 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,21 @@
import { MemoryHistory } from 'history';
import React from 'react';
import { MemoryRouter, MemoryRouterProps, matchPath } from 'react-router';
import { RouteManager } from './Router';
interface IonReactMemoryRouterProps extends MemoryRouterProps {
history: MemoryHistory;
}
export class IonReactMemoryRouter extends React.Component<IonReactMemoryRouterProps> {
render() {
const { children, history, ...props } = this.props;
const match = matchPath(history.location.pathname, this.props);
return (
<MemoryRouter {...props}>
<RouteManager history={history} location={history.location} match={match!}>{children}</RouteManager>
</MemoryRouter>
);
}
}