Как я могу удалить элемент из AsyncStorage, когда закрываю собственное приложение React?.
app. js:
state = {
appState: AppState.currentState
}
componentDidMount() {
AppState.addEventListener('change', this.handleAppStateChange);
}
componentWillUnmount() {
AppState.removeEventListener('change', this.handleAppStateChange);
}
handleAppStateChange = (nextAppState) => {
if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
AsyncStorage.removeItem('item');
console.log("App has come to the foreground!");
}
this.setState({ appState: nextAppState });
}
Я никогда не вижу ничего в console.log