如何使用React导航将用户ID存储在React Native中?

时间:2019-08-21 04:30:49

标签: react-native

How can check user is login or not

_bootstrapAsync =异步()=> {     const userToken =等待AsyncStorage.getItem('userToken');

// This will switch to the App screen or Auth screen and this loading
// screen will be unmounted and thrown away.

      _bootstrapAsync = async () => { const userToken = await 
 AsyncStorage.getItem('userToken');
if (userToken!=true) {
  alert("Session Expired!!");
this.props.navigation.navigate('Home');
}
    console.log("+++++++++++++++++++++++++++++++++++++++Working++++++++++++++++++++++++++++++");
  };

1 个答案:

答案 0 :(得分:0)

您需要执行AsyncStorage.setItem('userToken', userToken);来存储userToken

libraries