const ResolvedPlaces = ({navigation}) => {
return(
<View style={Styles.headerWrapper}>
<TouchableOpacity navigation={navigation} onPress={()=> navigation.navigate("ProfileScreen")} >
<Text style={[Styles.header,{fontWeight:"bold"}]}>Resolved </Text>
<Text style={Styles.header}> places</Text>
</TouchableOpacity>
</View>
)
}
I have created a ResolvedPlaces function and gave a option to route to the profile screen. Also I've destructured the "navigation" in all format. But I continuously got this navgation.navigate as undefined object. the error message on the terminal
If
ResolvedPlacesis not defined as aScreenin areact-native-navigation navigator, then thenavigation propwill not be passed automatically to the componentResolvedPlaces.If
ResolvedPlacesis nested inside aScreenthat is defined in aNavigator, then you can use thenavigation propdirectly. This could look as follows.The component
SomeScreenmust be defined in a navigator, e.g. aStack.If
ResolvedPlacesis a component defined in its own file, then pass thenavigationobject as a prop from the parent that is defined as a screen.If this is not an option than you can still use the
useNavigationhook as follows.Remarks: I have removed the navigation prop from the
TouchableOpacitysince this prop does not exist for this component. The basicreact-native-navigationstructure is documented here.