反应本机导航参数 returns 一个反应元素
react native navigation params returns an react element
我正在使用 @react-navigation/native-stack,当我尝试将参数从一个屏幕传递到另一个屏幕时,它 returns 在我记录参数时是一个反应元素。
我在平面列表中渲染该项目,它工作正常唯一的问题是名称:'CurrentMeet'
<FlatList
data={dummy_cards}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<>
<TouchableOpacity
onPress={() =>
navigation.navigate("MyMeetEvents", {
name: "CurrentMeet",
item,
})
}
>
<MeetInfoBlock
key={item.id}
meet_image={item.meet_image}
meet_location={item.location}
meet_title={item.title}
meet_datetime={item.datetime}
isTimed={item.isTimed}
events_count={item.events_count}
borderColor={Colors.secondaryColor}
/>
</TouchableOpacity>
</>
)}
/>
我收到了项目的适当回复
item--------------------------
"Object"{
"datetime":"08:00 - 14:00, 12 Jan 2022",
"events_count":14,
"id":1,
"isTimed":true,
"location":"Seattle, WA",
"meet_image":29,
"title":"Mile Stone Sports Meet"
}```
***But for the name iam getting this***
name--------------------------
```"Object"{
"$$typeof":"Symbol(react.element)",
"_owner":"FiberNode"{
"tag":0,
"key":null,
"type":[
"Function MyMeetEvents"
]
},
"_store":"Object"{
},
"key":null,
"props":"Object"{
"title":"Current Meet",
"type":"NavHeader"
},
"ref":null,
"type":[
"Function Header"
]
}```
试试这个:
onPress={() => navigation.navigate("MyMeetEvents", {
name: "CurrentMeet",
item,
});
}
如果您要传递硬编码值 CurrentMeet
,则通过参数传递此键值对信息 name: 'CurrentMeet'
没有意义。
直接使用那个屏幕...
希望你明白我的意思!
我正在使用 @react-navigation/native-stack,当我尝试将参数从一个屏幕传递到另一个屏幕时,它 returns 在我记录参数时是一个反应元素。
我在平面列表中渲染该项目,它工作正常唯一的问题是名称:'CurrentMeet'
<FlatList
data={dummy_cards}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<>
<TouchableOpacity
onPress={() =>
navigation.navigate("MyMeetEvents", {
name: "CurrentMeet",
item,
})
}
>
<MeetInfoBlock
key={item.id}
meet_image={item.meet_image}
meet_location={item.location}
meet_title={item.title}
meet_datetime={item.datetime}
isTimed={item.isTimed}
events_count={item.events_count}
borderColor={Colors.secondaryColor}
/>
</TouchableOpacity>
</>
)}
/>
我收到了项目的适当回复
item--------------------------
"Object"{
"datetime":"08:00 - 14:00, 12 Jan 2022",
"events_count":14,
"id":1,
"isTimed":true,
"location":"Seattle, WA",
"meet_image":29,
"title":"Mile Stone Sports Meet"
}```
***But for the name iam getting this***
name--------------------------
```"Object"{
"$$typeof":"Symbol(react.element)",
"_owner":"FiberNode"{
"tag":0,
"key":null,
"type":[
"Function MyMeetEvents"
]
},
"_store":"Object"{
},
"key":null,
"props":"Object"{
"title":"Current Meet",
"type":"NavHeader"
},
"ref":null,
"type":[
"Function Header"
]
}```
试试这个:
onPress={() => navigation.navigate("MyMeetEvents", {
name: "CurrentMeet",
item,
});
}
如果您要传递硬编码值 CurrentMeet
,则通过参数传递此键值对信息 name: 'CurrentMeet'
没有意义。
直接使用那个屏幕...
希望你明白我的意思!