I'm fetching data then saving them in a sqlite file on the mobile. When this screen is called the fetch code begins called by componentDidMount() function. When the fetch is over this does a setState() thus calls componenDidUpdate() function (saving the data in sqlite then setState= 'isLoadingDataProgramadas: false') so I want the application to make a transition to 'ActProgramadas' screen with React-Navigation V3. The solution below works, but gets me a warning:
Warning: Cannot update during an existing state (such as within 'render'). Render methods should be a pure function of props and state.
How can I fix that?
componentDidMount() {
this.doFetch();
}
componentDidUpdate(){
this.openBD();
this.insertSQLITE();
}
componentWillUnmount() {
this.closeDatabase();
}
render() {
if(this.state.isLoadingDataProgramadas)
return (
<View style={stylesLoading.container}>
<View>
<ActivityIndicator size="large" color="lightblue"/>
</View>
<View>
<Text style={stylesLoading.texto}>
Descargando datos...
</Text>
</View>
</View>
);
else
return(
<View>
{this.props.navigation.navigate('ActProgramadas')}
</View>
);
}