I have a question about AsyncStorage..
console.log(this.state.UserEmail);
AsyncStorage.setItem('email', JSON.stringify(this.state.UserEmail));
the console log logs the user's email perfectly fine, but for some reason when i try to do
AsyncStorage.getItem("email").then((res) => { this.setState({username: res })});
It seems that the AsyncStorage with the item name of "email" is empty.as it does not return anything if i console.log this.state.username.
Thanks in advance,
Mario
getItemimmediately aftersetItem?setItemis an async function, so it may not be complete immediately after. - TKoLAsyncStorage.getItem('email').then(async (res) => { const val = await res; this.setState({username: JSON.parse(val) }) }); console.log(this.props.navigation.state.params.id + " " + this.state.typing + " " + this.state.username);The params.id works, the this.state.typing works, but the this.state.username does not :/ - Mario