Calling a function when opening a react-native screen
use componentWillMount()
method. This will execute automatically before render()
method gets triggered.
class Sample extends Component{
state = {data : []};
componentWillMount(){
this.setState({data : inputObject});
}
render(){
return(
<View>
//you can render the data here
</View>
);
}
}
Reference: https://facebook.github.io/react/docs/react-component.html#componentwillmount