Given the following simplified app in react native:
import { AppRegistry } from 'react-native';
const App = () => {
useEffect(() => {
console.log('App mounted');
return () => {
console.log('App unmounted');
};
}, []);
<View>
<Text>Hello world</Text>
</View>;
};
AppRegistry.registerComponent(appName, () => App);
Under what circumstances would App
be unmounted, and the return function from the useEffect
be called?
My assumption was "never" (it's either backgrounded, crashed or killed), but that doesn't seem to be the case. We have a very small minority of users where app is sometimes closing, shortly after being background, and the disposer on the useEffect
is being called. And it only seems to be happening on Android.
Any clues?