我有一个问题:这是一个用户列表,我想向任何用户添加约会,因此在用户屏幕上,添加约会屏幕上的 PlusButton 发送用户(从用户屏幕的 headerRight 呈现的 PlusButton)。但我不知道如何传递给 AddAppointmentScreen 用户 ID,因为链接到屏幕不是通过按钮,而是通过 react-navigation v5。
这是我在 github 上的项目的链接
应用程序.js
const HeaderRight = ({ navigation, target }) => {
return (
<Button transparent onPress={() => navigation.navigate(target)}>
<Icon name='plus' type='Entypo' style={{ fontSize: 26 }} />
</Button>
)
}
<Stack.Screen
name='Patient'
component={PatientScreen}
options={{
title: '????? ????????',
headerTintColor: '#2A86FF',
headerTitleAlign: 'center',
headerTitleStyle: {
fontWeight: 'bold',
fontSize: 20,
},
headerBackTitleVisible: false,
headerRight: () => <HeaderRight navigation={navigation} target={'AddAppointment'} />,
}}
/>
Run Code Online (Sandbox Code Playgroud)
添加AppointmentScreen.js
import React, { useState } from 'react' …Run Code Online (Sandbox Code Playgroud)