【发布时间】:2020-09-21 08:42:20
【问题描述】:
我有一个简单的反应原生应用程序,我需要在按钮单击时导航到某个组件(ViewDrafts)。
我已经尝试过了,但出现了很多错误
const App = ({ navigation }) => {
//some code written here.
return (
<SafeAreaView style={styles.body}>
<View style={styles.container}>
<Text style={styles.title}>
Hi there! {"\n"}Welcome to Invoice Creator
</Text>
<TouchableOpacity style={styles.button} onPress={toggleVisible}>
<Text style={styles.content}>Create Invoice</Text>
</TouchableOpacity>
<Text></Text>
<TouchableOpacity
style={styles.button}
onPress={() => navigation.navigate("ViewDrafts.js")}
>
<Text style={styles.content}>View Drafts</Text>
</TouchableOpacity>
</View>
...
</SafeAreaView>
);
};
如你所见
<TouchableOpacity
style={styles.button}
onPress={() => navigation.navigate("ViewDrafts.js")}
>
<Text style={styles.content}>View Drafts</Text>
</TouchableOpacity>
但它不起作用! 请问有什么想法吗?
【问题讨论】:
-
你能告诉我们你是如何初始化导航的吗?堆栈 n 以便我们可以帮助您
-
能不能给我们看一次你的导航栈,你需要给导航栈中的组件名,而不是文件名navigation.navigate("ViewDrafts")}
标签: reactjs react-native navigation