mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 01:03:03 +08:00
22 lines
722 B
TypeScript
22 lines
722 B
TypeScript
import { MemoryHistory } from 'history';
|
|
import React from 'react';
|
|
import { MemoryRouter, MemoryRouterProps, matchPath } from 'react-router';
|
|
|
|
import { LocationState, RouteManager } from './Router';
|
|
|
|
interface IonReactMemoryRouterProps extends MemoryRouterProps {
|
|
history: MemoryHistory<LocationState>;
|
|
}
|
|
|
|
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>
|
|
);
|
|
}
|
|
}
|