我有以下2个屏幕:
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="SubScreen1" component={SubScreen1} />
我想将“SubScreen1”的屏幕名称更改为“Search Result”,但出现The action 'NAVIGATE' with payload {"name":"SubScreen1","params":{"paramKey":"Japanese"}} was not handled by any navigator.
错误
为什么我有这个错误,因为我有另一个屏幕,我只是改变了名称,没有错误。
在我的主屏幕中:
<View style = {styles.container}>
<Text>Welcome {auth.currentUser?.email}</Text>
<Text></Text>
<Text>What cusine would you like to eat today?</Text>
<DropDownPicker
open={open}
value={value}
items={items}
setOpen={setOpen}
setValue={setValue}
setItems={setItems}
/>
<TouchableOpacity
onPress={() => navigation.navigate("SubScreen1", {paramKey:value})}
style = {styles.button}
>
<Text style = {styles.buttonText}>Search</Text>
</TouchableOpacity>
在我的子屏幕1屏幕中
import { StyleSheet, Text, View } from 'react-native'
import React from 'react'
const SubScreen1 = ({route}) => {
const paramKey = route.params.paramKey
console.log(paramKey)
return (
<View>
<Text>{paramKey}</Text>
</View>
)
}
export default SubScreen1
const styles = StyleSheet.create({})
1条答案
按热度按时间cpjpxq1n1#
不确定我是否正确理解了您的问题,但如果您想将屏幕的标题文本更改为“搜索结果”,则只需在
Stack.Screen
options
中添加title
属性,如下所示https://reactnavigation.org/docs/headers/#setting-the-header-title