I’m just trying to do something like that (when user select an item, then navigate to another component):
JavaScript
x
27
27
1
const handleValueChange=(itemValue, itemIndex) =>setTypeValue(itemValue)
2
3
const onPress = () => {
4
5
try{
6
7
const topic = "Plant/type";
8
9
navigation.navigate('Air')
10
11
}catch(err){
12
console.log(err)
13
}
14
15
}
16
return (
17
<Picker
18
selectedValue={typeValue}
19
onValueChange={handleValueChange}
20
style={{ top: '21%', height: 50, width: 150 }}/>
21
22
<TouchableOpacity
23
style={styles.button}
24
onPress={()=> onPress()}
25
/>
26
)
27
Typically when we want to pass value between two component we use props :
JavaScript
1
2
1
<AirScreen typeofPlant={typeValue} />
2
But in this case I have o idea how can I do it without invoked AirScreen
Advertisement
Answer
Just do something like this:
JavaScript
1
2
1
navigation.navigate('RouteName', { /* params go here */ })
2
You might want to read the following documentation: https://reactnavigation.org/docs/params/