【发布时间】:2020-07-22 17:46:52
【问题描述】:
我正在尝试创建一个导航到另一个页面的登录按钮,但我不断收到未定义“导航”的错误
这是错误的屏幕截图: screenshot here
screenshot here 这就是应用组件:
export default function App({navigation}) {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<Image
source={logo}
style={styles.stretch}
/>
<Image
source={logo2}
style={styles.stretch2}
/>
<Button title="Login" style={[styles.buttonContainer, styles.loginButton,styles.top]} onPress={() => navigation.navigate("Details")} >
<Text style={styles.loginText}>LOG IN</Text>
</Button>
<TouchableHighlight style={[styles.buttonContainer2, styles.loginButton2,styles.top2]} >
<Text style={styles.loginText2}>Register</Text>
</TouchableHighlight>
<NavigationContainer>
<Stack.Navigator >
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Details" component={Details} />
</Stack.Navigator>
</NavigationContainer>
</View>
);
}
在这里我在使用导航 Ref 方法后卡住了: link here
【问题讨论】:
标签: react-native expo stack-navigator