hi everyone i'm just learning react native and i have a question. when I click on a button, can I call up a method and change the screen at the same time? If I have for example the following piece of code:
HomePage.js
export default class HomePage extends Component {
constructor(props){
super(props);
this.state = {
aa:""
}
}
function(){
this.setState({aa:"ok"})
console.log(this.state.aa)
}
render(){
return(<View>
<Button onPress={ ()=>this.function();this.props.navigation.navigate('Menu')}
title="DETAILE" color="orange"/>
</View> >
)}
}
How can I call up a function and change the screen at the same time?
CodePudding user response:
Button onPress={ ()=>{this.function(),this.props.navigation.navigate('Menu')}}
title="DETAILE" color="orange"/>