mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[react-navigation] Add test to navigate to next screen
This commit is contained in:
parent
4ba39d4016
commit
cf39e7e9bd
@ -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 />
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user