mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 19:12:20 +08:00
Merge pull request #25667 from tbrannam/tbrannam-navigator-register
Allow additional options to be passed via `registerComponent`
This commit is contained in:
2
types/react-native-navigation/index.d.ts
vendored
2
types/react-native-navigation/index.d.ts
vendored
@@ -7,7 +7,7 @@
|
||||
import * as React from 'react';
|
||||
|
||||
export namespace Navigation {
|
||||
function registerComponent(screenID: string, generator: () => React.ComponentType<any>, store?: any, provider?: any): void;
|
||||
function registerComponent(screenID: string, generator: () => React.ComponentType<any>, store?: any, provider?: any, options?: any): void;
|
||||
function startTabBasedApp(params: TabBasedApp): void;
|
||||
function startSingleScreenApp(params: SingleScreenApp): void;
|
||||
function showModal(params: ModalScreen): void;
|
||||
|
||||
@@ -63,7 +63,23 @@ const Drawer = (props: NavigationComponentProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
Navigation.registerComponent('example.Screen1', () => Screen1);
|
||||
interface TestProviderProps {
|
||||
test: string;
|
||||
}
|
||||
|
||||
class TestProvider extends React.Component<TestProviderProps> {
|
||||
getChildContext() {
|
||||
return {
|
||||
test: this.props.test
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
Navigation.registerComponent('example.Screen1', () => Screen1, {}, TestProvider, {test: "test"});
|
||||
Navigation.registerComponent('example.Screen2', () => Screen2);
|
||||
Navigation.registerComponent('example.Drawer', () => Drawer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user