diff --git a/packages/react-router/src/ReactRouter/IonReactMemoryRouter.tsx b/packages/react-router/src/ReactRouter/IonReactMemoryRouter.tsx new file mode 100644 index 00000000000..4367569e2d2 --- /dev/null +++ b/packages/react-router/src/ReactRouter/IonReactMemoryRouter.tsx @@ -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 { + render() { + const { children, history, ...props } = this.props; + const match = matchPath(history.location.pathname, this.props); + return ( + + {children} + + ); + } +} diff --git a/packages/react-router/src/ReactRouter/Router.tsx b/packages/react-router/src/ReactRouter/Router.tsx index 164165a3895..318a1b9ab82 100644 --- a/packages/react-router/src/ReactRouter/Router.tsx +++ b/packages/react-router/src/ReactRouter/Router.tsx @@ -19,7 +19,7 @@ interface RouteManagerState extends RouteManagerContextState { action?: IonRouteAction; } -class RouteManager extends React.Component { +export class RouteManager extends React.Component { listenUnregisterCallback: UnregisterCallback | undefined; activeIonPageId?: string; currentIonRouteAction?: IonRouteAction; diff --git a/packages/react-router/src/ReactRouter/index.ts b/packages/react-router/src/ReactRouter/index.ts index 6e8cbe62118..e462884c140 100644 --- a/packages/react-router/src/ReactRouter/index.ts +++ b/packages/react-router/src/ReactRouter/index.ts @@ -1,2 +1,3 @@ export { IonReactRouter } from './IonReactRouter'; export { IonReactHashRouter } from './IonReactHashRouter'; +export { IonReactMemoryRouter } from './IonReactMemoryRouter';