Skip to content

Commit

Permalink
fix(react): add missing react memory router
Browse files Browse the repository at this point in the history
  • Loading branch information
elylucas committed Jan 13, 2020
1 parent 676cc19 commit 8a5aba2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions 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<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>
);
}
}
2 changes: 1 addition & 1 deletion packages/react-router/src/ReactRouter/Router.tsx
Expand Up @@ -19,7 +19,7 @@ interface RouteManagerState extends RouteManagerContextState {
action?: IonRouteAction;
}

class RouteManager extends React.Component<RouteComponentProps, RouteManagerState> {
export class RouteManager extends React.Component<RouteComponentProps, RouteManagerState> {
listenUnregisterCallback: UnregisterCallback | undefined;
activeIonPageId?: string;
currentIonRouteAction?: IonRouteAction;
Expand Down
1 change: 1 addition & 0 deletions packages/react-router/src/ReactRouter/index.ts
@@ -1,2 +1,3 @@
export { IonReactRouter } from './IonReactRouter';
export { IonReactHashRouter } from './IonReactHashRouter';
export { IonReactMemoryRouter } from './IonReactMemoryRouter';

0 comments on commit 8a5aba2

Please sign in to comment.