AsyncStorage not fulfilling promise #17282
Labels
Ran Commands
One of our bots successfully processed a command.
Resolution: Locked
This issue was locked by the bot.
Issue
I am using NetInfo and asyncstorage in my project.
The promise of NetInfo works fine, after getting the response from NetInfo I'm getting the value of a flag from AsyncStorage.The issue is sometimes the response (flag from Asyncstorage) is resolved, sometimes it doesn't. It happens on the very first launch of the application always.
And my application requires that the promise should be returned from Asyncstorage .
The following code executes inside React Native component lifecycle's:
componentWillMount(){
this.setState({loading:true});
NetInfo.isConnected.fetch().then(isConnected => {
console.log('isconnected ' + (isConnected ? 'online' : 'offline'));
(isConnected?this.setState({net:true}):this.setState({net:false}))
// Alert.alert('Netwrok',this.state.net)
}).then(()=>{
global.internetStatus=this.state.net;
console.log('going in db');
})
Environment:
OS: macOS Sierra 10.13.1
Node: 8.4.0
npm: 3.10.10
Watchman: 4.7.0
Packages:
react-native: 0.50.3
react: 16.0.0
Target Platform:Android(6.0)
The text was updated successfully, but these errors were encountered: