Hello I set the value of AsyncStorage.getItem('authStatus') on LoginPage but the problem is that the Navigator class doesnt respond to value change of AsyncStorage. How to add listener to AsyncStorage.getItem('authStatus')?
export default class Navigator extends React.Component {
constructor(props) {
super(props);
this.state = { authStatus: ''}
}
async componentDidMount() {
var authStatus = await AsyncStorage.getItem('authStatus');
**DOESN'T WORK ->** authStatus.addListener(authStatus => {
this.setState(this.state.authStatus = authStatus)
});
console.log("authStatus =")
console.log(this.state.authStatus)
SplashScreen.hide()
}
render() {
return (
(this.state.authStatus == 'authenticated')
?
this.Home()
:
this.AuthStackScreen()
);
}