-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathIonRouterOutlet.tsx
More file actions
63 lines (52 loc) · 1.81 KB
/
IonRouterOutlet.tsx
File metadata and controls
63 lines (52 loc) · 1.81 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type { JSX as LocalJSX } from '@ionic/core/components';
import React from 'react';
import { NavContext } from '../contexts/NavContext';
import OutletPageManager from '../routing/OutletPageManager';
import type { IonicReactProps } from './IonicReactProps';
import { IonRouterOutletInner } from './inner-proxies';
import { createForwardRef } from './utils';
type Props = LocalJSX.IonRouterOutlet & {
basePath?: string;
ref?: React.Ref<any>;
ionPage?: boolean;
};
interface InternalProps extends Props {
forwardedRef?: React.ForwardedRef<HTMLIonRouterOutletElement>;
children: React.ReactNode;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface InternalState {}
class IonRouterOutletContainer extends React.Component<InternalProps, InternalState> {
context!: React.ContextType<typeof NavContext>;
constructor(props: InternalProps) {
super(props);
}
render() {
const StackManager = this.context.getStackManager();
const { children, forwardedRef, ...props } = this.props;
return this.context.hasIonicRouter() ? (
props.ionPage ? (
<OutletPageManager StackManager={StackManager} routeInfo={this.context.routeInfo} {...props}>
{children}
</OutletPageManager>
) : (
<StackManager routeInfo={this.context.routeInfo}>
<IonRouterOutletInner {...props} forwardedRef={forwardedRef}>
{children}
</IonRouterOutletInner>
</StackManager>
)
) : (
<IonRouterOutletInner ref={forwardedRef} {...this.props}>
{this.props.children}
</IonRouterOutletInner>
);
}
static get contextType() {
return NavContext;
}
}
export const IonRouterOutlet = createForwardRef<Props & IonicReactProps, HTMLIonRouterOutletElement>(
IonRouterOutletContainer,
'IonRouterOutlet'
);