[react-navigation] Add test to navigate to next screen

This commit is contained in:
abrahambotros 2017-06-15 08:48:33 -07:00
parent 4ba39d4016
commit cf39e7e9bd

View File

@ -1,5 +1,8 @@
import * as React from 'react';
import { View } from 'react-native';
import {
TouchableOpacity,
View,
} from 'react-native';
import {
addNavigationHelpers,
NavigationScreenProps,
@ -28,6 +31,40 @@ class StartScreen extends React.Component<StartScreenProps, {}> {
const id = this.props.navigation.state.params.id;
const s = this.props.navigation.state.params.s;
return (
<View>
<TouchableOpacity onPress={this.navigateToNextScreen} />
</View>
);
}
private navigateToNextScreen = (): void => {
this.props.navigation.navigate(
ROUTE_NAME_NEXT_SCREEN,
{
id: this.props.navigation.state.params.id,
name: this.props.navigation.state.params.s,
} as NextScreenComponentProps,
);
}
}
/**
* @class NextScreen @extends React.Component
*/
const ROUTE_NAME_NEXT_SCREEN = "NextScreen";
interface NextScreenComponentProps {
id: number,
name: string,
}
interface NextScreenProps extends NavigationScreenProps<NextScreenComponentProps> { }
class NextScreen extends React.Component<NextScreenProps, {}> {
render() {
// Implicit type checks.
const navigationStateParams: NextScreenComponentProps = this.props.navigation.state.params;
const id = this.props.navigation.state.params.id;
const name = this.props.navigation.state.params.name;
return (
<View />
);