mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 17:42:15 +08:00
fix(react): add missing react memory router
This commit is contained in:
@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,7 @@ interface RouteManagerState extends RouteManagerContextState {
|
|||||||
action?: IonRouteAction;
|
action?: IonRouteAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RouteManager extends React.Component<RouteComponentProps, RouteManagerState> {
|
export class RouteManager extends React.Component<RouteComponentProps, RouteManagerState> {
|
||||||
listenUnregisterCallback: UnregisterCallback | undefined;
|
listenUnregisterCallback: UnregisterCallback | undefined;
|
||||||
activeIonPageId?: string;
|
activeIonPageId?: string;
|
||||||
currentIonRouteAction?: IonRouteAction;
|
currentIonRouteAction?: IonRouteAction;
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export { IonReactRouter } from './IonReactRouter';
|
export { IonReactRouter } from './IonReactRouter';
|
||||||
export { IonReactHashRouter } from './IonReactHashRouter';
|
export { IonReactHashRouter } from './IonReactHashRouter';
|
||||||
|
export { IonReactMemoryRouter } from './IonReactMemoryRouter';
|
||||||
|
Reference in New Issue
Block a user