#react-navigation 导航右侧添加事件
#导航设置
import Component from './Component'
<Stack.Screen
name="Component"
component={Component}
options={({ navigation, route }:any) => ({
title: route.params.title,
headerLeft:() => {
return(<GoBack navigation={navigation} />)
},
headerRight:() => {
return( <HeaderRight singleEvent={()=>{ route.params.navigatePress() }} text="完成" /> )
}
})}
/>
#Component 页面设置
componentDidMount(){
this.props.navigation.setParams({
navigatePress: this.navigatePress
})
}
navigatePress = () => {
console.log('事件')
}