[react-navigation] Minor fixes

This commit is contained in:
abrahambotros
2017-06-18 15:21:51 -07:00
parent dbdfb4a24f
commit c5ab866dbc
2 changed files with 16 additions and 11 deletions
+4 -4
View File
@@ -592,10 +592,10 @@ export namespace NavigationActions {
* BEGIN CUSTOM CONVENIENCE INTERFACES
*/
export interface NavigationScreenProps<ComponentProps> {
navigation: NavigationScreenProp<NavigationRoute<ComponentProps>, NavigationAction>,
screenProps: { [key: string]: any },
navigationOptions: any,
export interface NavigationScreenProps<Params> {
navigation: NavigationScreenProp<NavigationRoute<Params>, NavigationAction>,
screenProps?: { [key: string]: any },
navigationOptions?: NavigationScreenConfig<any>,
}
/**
@@ -19,15 +19,15 @@ import {
* @desc Simple screen component class with typed component props that should
* receive the navigation prop from the AppNavigator.
*/
interface StartScreenComponentProps {
interface StartScreenNavigationParams {
id: number,
s: string,
}
interface StartScreenProps extends NavigationScreenProps<StartScreenComponentProps> { }
interface StartScreenProps extends NavigationScreenProps<StartScreenNavigationParams> { }
class StartScreen extends React.Component<StartScreenProps, {}> {
render() {
// Implicit type checks.
const navigationStateParams: StartScreenComponentProps = this.props.navigation.state.params;
const navigationStateParams: StartScreenNavigationParams = this.props.navigation.state.params;
const id = this.props.navigation.state.params.id;
const s = this.props.navigation.state.params.s;
@@ -43,7 +43,7 @@ class StartScreen extends React.Component<StartScreenProps, {}> {
{
id: this.props.navigation.state.params.id,
name: this.props.navigation.state.params.s,
} as NextScreenComponentProps,
} as NextScreenNavigationParams,
);
}
@@ -53,15 +53,15 @@ class StartScreen extends React.Component<StartScreenProps, {}> {
* @class NextScreen @extends React.Component
*/
const ROUTE_NAME_NEXT_SCREEN = "NextScreen";
interface NextScreenComponentProps {
interface NextScreenNavigationParams {
id: number,
name: string,
}
interface NextScreenProps extends NavigationScreenProps<NextScreenComponentProps> { }
interface NextScreenProps extends NavigationScreenProps<NextScreenNavigationParams> { }
class NextScreen extends React.Component<NextScreenProps, {}> {
render() {
// Implicit type checks.
const navigationStateParams: NextScreenComponentProps = this.props.navigation.state.params;
const navigationStateParams: NextScreenNavigationParams = this.props.navigation.state.params;
const id = this.props.navigation.state.params.id;
const name = this.props.navigation.state.params.name;
@@ -71,6 +71,10 @@ class NextScreen extends React.Component<NextScreenProps, {}> {
}
}
const initialRouteParams: StartScreenNavigationParams = {
id: 1,
s: "Start",
};
export const AppNavigator = StackNavigator({
StartImage: {
path: 'startImage',
@@ -78,6 +82,7 @@ export const AppNavigator = StackNavigator({
},
}, {
initialRouteName: 'StartImage',
initialRouteParams,
});
const Router = (props: any) => (