mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Add NavigationContainerComponent (#25270)
This commit is contained in:
committed by
Wesley Wigham
parent
b3ce091e34
commit
e81f217c01
10
types/react-navigation/index.d.ts
vendored
10
types/react-navigation/index.d.ts
vendored
@@ -600,9 +600,17 @@ export interface NavigationContainerProps {
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
export interface NavigationContainerComponent extends React.Component<
|
||||
NavigationContainerProps & NavigationNavigatorProps<any>
|
||||
> {
|
||||
dispatch: NavigationDispatch;
|
||||
}
|
||||
|
||||
export interface NavigationContainer extends React.ComponentClass<
|
||||
NavigationContainerProps & NavigationNavigatorProps<any>
|
||||
> {
|
||||
> {
|
||||
new(props: NavigationContainerProps & NavigationNavigatorProps<any>, context?: any): NavigationContainerComponent;
|
||||
|
||||
router: NavigationRouter<any, any>;
|
||||
screenProps: { [key: string]: any };
|
||||
navigationOptions: any;
|
||||
|
||||
@@ -33,10 +33,12 @@ import {
|
||||
addNavigationHelpers,
|
||||
HeaderBackButton,
|
||||
Header,
|
||||
NavigationContainer,
|
||||
NavigationParams,
|
||||
NavigationPopAction,
|
||||
NavigationPopToTopAction,
|
||||
NavigationScreenComponent,
|
||||
NavigationContainerComponent,
|
||||
} from 'react-navigation';
|
||||
|
||||
// Constants
|
||||
@@ -422,3 +424,23 @@ const popToTopAction: NavigationPopToTopAction = NavigationActions.popToTop({
|
||||
key: "foo",
|
||||
immediate: true
|
||||
});
|
||||
|
||||
class Page1 extends React.Component { }
|
||||
|
||||
const RootNavigator: NavigationContainer = SwitchNavigator({
|
||||
default: { getScreen: () => Page1 },
|
||||
});
|
||||
|
||||
class Page2 extends React.Component {
|
||||
navigatorRef: NavigationContainerComponent | null;
|
||||
|
||||
componentDidMount() {
|
||||
if (this.navigatorRef) {
|
||||
this.navigatorRef.dispatch(NavigationActions.navigate({ routeName: 'default' }));
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return <RootNavigator ref={(instance: NavigationContainerComponent | null): void => { this.navigatorRef = instance; }} />;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user