/
IonRouterOutlet.tsx
46 lines (35 loc) · 1.29 KB
/
IonRouterOutlet.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { JSX as LocalJSX } from '@ionic/core';
import React from 'react';
import { NavContext } from '../contexts/NavContext';
import { IonicReactProps } from './IonicReactProps';
import { IonRouterOutletInner } from './inner-proxies';
import { createForwardRef } from './utils';
type Props = LocalJSX.IonRouterOutlet & {
ref?: React.RefObject<any>;
};
type InternalProps = Props & {
forwardedRef?: React.RefObject<HTMLIonRouterOutletElement>;
};
const IonRouterOutletContainer = /*@__PURE__*/(() => class extends React.Component<InternalProps> {
context!: React.ContextType<typeof NavContext>;
render() {
const StackManager = this.context.getStackManager();
return (
this.context.hasIonicRouter() ? (
<StackManager>
<IonRouterOutletInner ref={this.props.forwardedRef} {...this.props}>
{this.props.children}
</IonRouterOutletInner>
</StackManager>
) : (
<IonRouterOutletInner ref={this.props.forwardedRef} {...this.props}>
{this.props.children}
</IonRouterOutletInner>
)
);
}
static get contextType() {
return NavContext;
}
})();
export const IonRouterOutlet = createForwardRef<Props & IonicReactProps, HTMLIonRouterOutletElement>(IonRouterOutletContainer, 'IonRouterOutlet');