Hello developers i am using AsyncStorage in react native i am using it this way:
const AppLanguage = createStackNavigator({
ChooseLanguage: {
screen: ChooseLanguage,
},
AppIntroScreen: {
screen: AppIntroScreen,
},
}, {
headerMode: 'none',
cardStyle: {
backgroundColor: "#ffffff",
},
navigationOptions: {
headerVisible: false,
}
});
retrieve = () => AsyncStorage.getItem('first').then(value => {
return value;
});
console.log(retrieve()) //return promise but need to extract value from asyncstorage
AppRegistry.registerComponent(appName, () =>
retrieve() == 'true' ? AppIntroScreen:AppLanguage //problem here value not extracted from asyncstorage
)
here i am using the retreive method to get value of the key='first' so if the key is equal to 'true' it is opening first the AppIntroScreen else it is opening first the ChooseLanguage screen so please help!
you can't use app AppRegistry like that it doesn't recognize the screens or navigation. Make a new screen called entry in the asynccomponent did mount run your await retrieve function and navigate to the right screen based on that.