【发布时间】:2021-02-09 17:29:17
【问题描述】:
我的 App.js 中有以下 Stack.Screen,想在另一个屏幕中访问它,但不知道如何操作。
App.js 文件: 使用:{ id: route.params } - 当我使用 console.log(id) 时,它会准确返回 id。现在我想在以下内容中返回相同的 id:<Text>Edit Screen - {id}</Text>
<Stack.Screen name='ShowScreen'
component={ShowScreen}
options={({route, navigation}) => ({
title: 'Post Details',
headerRight: () => (
<TouchableOpacity onPress={() => navigation.navigate('Edit', { id: route.params })}>
<AntDesign name="edit" style={styles.iconStyle} />
</TouchableOpacity>
)
})}
/>
EditScreen.js 文件
import React from 'react'
import { View, Text, StyleSheet } from 'react-native'
const EditScreen = ({route}) => {
const { id } = route.params
console.log(id)
return (
<View>
<Text>Edit Screen - {}</Text>
</View>
)
}
const styles = StyleSheet.create({
//
})
export default EditScreen
【问题讨论】:
标签: react-native stack-navigator