From 8a5aba206865ce2af7f8bb85f4e7cd8dec37831d Mon Sep 17 00:00:00 2001 From: Ely Lucas Date: Mon, 13 Jan 2020 09:08:34 -0700 Subject: [PATCH] fix(react): add missing react memory router --- .../src/ReactRouter/IonReactMemoryRouter.tsx | 21 +++++++++++++++++++ .../react-router/src/ReactRouter/Router.tsx | 2 +- .../react-router/src/ReactRouter/index.ts | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 packages/react-router/src/ReactRouter/IonReactMemoryRouter.tsx diff --git a/packages/react-router/src/ReactRouter/IonReactMemoryRouter.tsx b/packages/react-router/src/ReactRouter/IonReactMemoryRouter.tsx new file mode 100644 index 0000000000..4367569e2d --- /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 164165a389..318a1b9ab8 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 6e8cbe6211..e462884c14 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';