I want to AsyncStorage
save data in variable without onPress
, show data on open app screen
code:
const AppScreen = () => {
var getusername = async () => {
await AsyncStorage.getItem('name');
};
return (
<Text>{getusername}</Text>
);
};
export default AppScreen;
You have to use react hooks, in particular, useEffect hook to call the function as the app launches
const appScreen = () => { var getusername = async () => { await AsyncStorage.getItem('token'); };};
useEffect(() => { appScreen ();}, []);