Hey I'm new to React Native so I'm sorry if this is a stupid question. I'm trying to store the email input during the login so that I can get it on a different page but when I console log the value I get from Asyncstorage I get the following:
Promise {
"_U": 0,
"_V": 0,
"_W": null,
"_X": null,
}
Here is the relevant code where I store the value:
import AsyncStorage from '@react-native-async-storage/async-storage';
const storeData = async (email) => {
try {
await AsyncStorage.setItem('loginEmail', email)
} catch (e) {
console.log(e);
}
}
<Form
initialValues={{ email: "", password: "" }}
onSubmit={storeData, handleSubmit}
validationSchema={validationSchema}
>
<ErrorMessage error="Invalid email and/or password." visible={loginFailed} />
<FormField
autoCapitalize="none"
autoCorrect={false}
icon="email"
keyboardType="email-address"
name="email"
placeholder="Email"
textContentType="emailAddress"
/>
<FormField
autoCapitalize="none"
autoCorrect={false}
icon="lock"
name="password"
placeholder="Password"
secureTextEntry
textContentType="password"
/>
<SubmitButton title="Login" />
</Form>
And here this is where I'm trying to get the value from Asyncstorage on a different file:
const getData = async () => {
try {
const value = await AsyncStorage.getItem('loginEmail')
if(value !== null) {
// value previously stored
return value;
}
} catch(e) {
// error reading value
console.log(e)
}
}
function AccountScreen({ navigation }) {
const { user, logOut } = useAuth();
const emailInfo = getData();
console.log(emailInfo);
If there's any info I need to add or clarify please let me know.