diff --git a/packages/react-router/src/ReactRouter/IonReactHashRouter.tsx b/packages/react-router/src/ReactRouter/IonReactHashRouter.tsx new file mode 100644 index 00000000000..dc87cc22a08 --- /dev/null +++ b/packages/react-router/src/ReactRouter/IonReactHashRouter.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { HashRouter, HashRouterProps } from 'react-router-dom'; + +import { RouteManagerWithRouter } from './Router'; + +export const IonReactHashRouter = /*@__PURE__*/ (() => class IonReactHashRouterInternal extends React.Component { + render() { + console.log('hash router in your bundle!!!'); + const { children, ...props } = this.props; + return ( + + {children} + + ); + } +})(); diff --git a/packages/react-router/src/ReactRouter/IonReactRouter.tsx b/packages/react-router/src/ReactRouter/IonReactRouter.tsx new file mode 100644 index 00000000000..259739d8b81 --- /dev/null +++ b/packages/react-router/src/ReactRouter/IonReactRouter.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { BrowserRouter, BrowserRouterProps } from 'react-router-dom'; + +import { RouteManagerWithRouter } from './Router'; + +export const IonReactRouter = /*@__PURE__*/ (() => class IonReactRouterInternal extends React.Component { + render() { + const { children, ...props } = this.props; + return ( + + {children} + + ); + } +})(); diff --git a/packages/react-router/src/ReactRouter/NavManager.tsx b/packages/react-router/src/ReactRouter/NavManager.tsx index 2e3183c2a09..1423090fdf9 100644 --- a/packages/react-router/src/ReactRouter/NavManager.tsx +++ b/packages/react-router/src/ReactRouter/NavManager.tsx @@ -15,6 +15,7 @@ interface NavManagerProps extends RouteComponentProps { findViewInfoByLocation: (location: HistoryLocation) => { view?: ViewItem, viewStack?: ViewStack }; findViewInfoById: (id: string) => { view?: ViewItem, viewStack?: ViewStack }; getActiveIonPage: () => { view?: ViewItem, viewStack?: ViewStack }; + onNavigate: (type: 'push' | 'replace', path: string, state?: any) => void; } export class NavManager extends React.Component { @@ -27,8 +28,6 @@ export class NavManager extends React.Component true, - getHistory: this.getHistory.bind(this), - getLocation: this.getLocation.bind(this), navigate: this.navigate.bind(this), getStackManager: this.getStackManager.bind(this), getPageManager: this.getPageManager.bind(this), @@ -66,36 +65,28 @@ export class NavManager extends React.Component { listenUnregisterCallback: UnregisterCallback | undefined; activeIonPageId?: string; + currentDirection?: RouterDirection; constructor(props: RouteComponentProps) { super(props); this.listenUnregisterCallback = this.props.history.listen(this.historyChange.bind(this)); + this.handleNavigate = this.handleNavigate.bind(this); this.state = { viewStacks: new ViewStacks(), hideView: this.hideView.bind(this), @@ -57,6 +59,8 @@ class RouteManager extends React.Component this.state.viewStacks.findViewInfoById(id)} findViewInfoByLocation={(location: HistoryLocation) => this.state.viewStacks.findViewInfoByLocation(location)} getActiveIonPage={() => this.state.viewStacks.findViewInfoById(this.activeIonPageId)} @@ -282,16 +295,5 @@ class RouteManager extends React.Component { - render() { - const { children, ...props } = this.props; - return ( - - {children} - - ); - } -} diff --git a/packages/react-router/src/ReactRouter/index.ts b/packages/react-router/src/ReactRouter/index.ts index f36dd643594..6e8cbe62118 100644 --- a/packages/react-router/src/ReactRouter/index.ts +++ b/packages/react-router/src/ReactRouter/index.ts @@ -1,2 +1,2 @@ - -export { IonReactRouter } from './Router'; +export { IonReactRouter } from './IonReactRouter'; +export { IonReactHashRouter } from './IonReactHashRouter'; diff --git a/packages/react/src/components/navigation/IonTabBar.tsx b/packages/react/src/components/navigation/IonTabBar.tsx index 9b977077469..4bb9593c06c 100644 --- a/packages/react/src/components/navigation/IonTabBar.tsx +++ b/packages/react/src/components/navigation/IonTabBar.tsx @@ -72,7 +72,7 @@ const IonTabBarUnwrapped = /*@__PURE__*/(() => class extends React.Component History; - getLocation: () => Location; getPageManager: () => any; getStackManager: () => any; goBack: (defaultHref?: string) => void; @@ -15,8 +13,6 @@ export interface NavContextState { } export const NavContext = /*@__PURE__*/React.createContext({ - getHistory: () => window.history, - getLocation: () => window.location, getPageManager: () => undefined, getStackManager: () => undefined, goBack: (defaultHref?: string) => {