I am trying to check before loading App, if AsyncStorage
value for key login exist or not , it does shows that value exist after looking into console value, but screen value never gets updated. any help would be highly appreciated
export default function App() {
let screen = null;
const getData = async () => {
try {
value1 = await AsyncStorage.getItem("login");
if (value1 != null) {
screen = 1;
console.warn(value1);
} else {
screen = 2;
}
} catch (e) {
// error reading value
}
};
useEffect(() => {
getData();
}, []);
return <View>{screen}</View>;
}