WARN Tried to show an alert while not attached to an Activity REACT-NATIVE

Viewed 348

Sometimes i get this error, but i really dont know whats causing this or where its come from, this error only appears when i unmount the component:

 componentDidMount() {
    this.track_changed = TrackPlayer.addEventListener("playback-track-changed", this.play_selected_music);
    this.requestPermission();
}

componentWillUnmount() {
    this.track_changed.remove();
    TrackPlayer.pause().then(() => {
        TrackPlayer.destroy();
    });
}

when unmount, remove all the listeners then pause and destroy the player, when i open the app again, soooome times it appears and also some times appears and alert showing error: null, but cant find where its coming from, im using some helpers functions to fetch data, but i think therey not the issue:

  export const Fetch_options = async () => {
    try {
        const options = JSON.parse(await AsyncStorage.getItem("options"));
        if (options != null) {
            return options;
        }else {
            return false;
        }
    }catch(error) {
        alert("hola" + error);
    }
}

export const Fetch_Lycrics = async () => {
    try {
        const lycrics = JSON.parse(await AsyncStorage.getItem("lycrics"));
        if (lycrics != null) {
            return lycrics;
        }else {
            return null;
        }
    }catch(error) {
        alert("hola" + error);
    }
}
0 Answers
Related