I'm using the AppState to reset the states of the App when the AppState is "background", but when I ask for a Permission, for example Camera or Location, the AppState change to "background", so it reset all my states. There's a way to control when the Pop Up permission appear so it doesn't reset the states on pop up Permissions?
<TouchableOpacity
onPress={() => {
setChangeAppState(false);
FunctionsWorkersList.chooseSource(item);
}}>
Here i change the state for not doing nothing on background, but it keeps reseting me the states there:
useEffect(() => {
if (changeAppState == false) {
console.log("state changed")
} else {
const appStateListener = AppState.addEventListener(
'change',
nextAppState => {
if (
(nextAppState == 'background' ||
nextAppState == 'inactive') &&
changeAppState == false
) {
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [
{ name: 'HomeWorkerScreen' },
{ name: 'GetLogsScreen' },
{ name: 'WorkersListScreen' },
{ name: 'CardsListScreen' },
],
}),
);
}
},
);
return () => {
appStateListener?.remove();
};
}
}, [changeAppState]);
It seems like don't have time to change the state?