我正在尝试使用React native构建一个Contact App。我想将电话号码和名称传递给另一个屏幕,方法是从联系人列表中按每个按钮。
答案 0 :(得分:0)
考虑查看React Navigation文档:
<Button
title="Details"
onPress={() => {
/* 1. Navigate to the Details route with params */
this.props.navigation.navigate('Details', {
1stParamData: 'anything you want here',
2ndParamData: 'anything you want here',
});
}}
/>
然后在您的导航屏幕中
const data= this.props.navigation.getParam('1stParamData', 'NO-ID');
//NO-ID is a fallback when there's no data.