React native React Native在onPress事件上发送2个值,然后传递到另一个屏幕

React native React Native在onPress事件上发送2个值,然后传递到另一个屏幕,react-native,react-native-flatlist,React Native,React Native Flatlist,这是我的JSON文件 { "name": "Thịt bò", "noed": 5 }, { "name": "Thịt heo", "noed": 3 } 我把他们送到公寓 <FlatList data={cats} keyExtractor={item => item.name} renderItem={({item})=>( <View>

这是我的JSON文件

{
    "name": "Thịt bò",
    "noed": 5
},
{
    "name": "Thịt heo",
    "noed": 3
}
我把他们送到公寓

   <FlatList
      data={cats}
      keyExtractor={item => item.name}
      renderItem={({item})=>(
          <View>
              <Text style={styles.catsItem} onPress={() => this.changeTextInput(item.name)}>{item.name} {item.noed}</Text>
          </View>
      )}
/>
但我不知道如何将
item.noed
发送到文本输入,以及如何将它们发送到另一个屏幕。
我是新手,请帮助我。

使用react navigation npm包从一个屏幕重定向到另一个屏幕,您也可以传递值

这有两个方面:

通过将参数作为导航的第二个参数放入对象中,将参数传递给路由。导航功能:

this.props.navigation.navigate
('RouteName', { /* params go here */ })




onPress={()=>this.props.navigation.navigate('Details', 
    { itemId: 86, otherParam: 'anything you want here', })};
读取屏幕组件中的参数:

this.props.navigation.getParam(paramName, defaultValue)
有关更多信息,请阅读以下文档


您是否在使用
react导航
?您基本上希望将用户键入的输入值存储到组件状态。查看文档:
onChangeText={(text)=>this.setState({text}}
。要进行调试,请记录渲染中的状态,以查看它是否真的保存到状态`render(){console.log(this.state);返回
this.props.navigation.getParam(paramName, defaultValue)