Closed
Description
The function for detecting when a component will be unmounted seems to never be fired on the root component, or a navigation component.
My root component has a very simple componentWillUnmount
with just a console log line, and a similar one exists inside the navigation route open at the time. As it stands, neither of these are called in debug when the app reloads the JS from the bundler, when the app is closed from Xcode, nor when the app is closed within iOS
React Native version:
React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
Memory: 1.21 GB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
IDEs:
Xcode: /undefined - /usr/bin/xcodebuild
npmPackages:
react: 16.6.3 => 16.6.3
react-native: 0.57.8 => 0.57.8
npmGlobalPackages:
react-native-cli: 2.0.1
react-native: 0.59.5
Steps To Reproduce
- Run the following App.js on an iOS device from Xcode
- Enable auto-refresh
- Add a new line somewhere in the App.js
- Notice no unmounting log line
- Close the app
- Notice no unmounting log line
import React, {Component} from 'react';
import {AppState, View} from 'react-native';
//return navigator
export default class App extends Component {
componentDidMount() {
console.debug('!!! App Mounted');
}
componentWillUnmount () {
console.debug('!!! App Unmounting');
}
_handleAppStateChange(nextAppState) {
console.debug('!!! App state', nextAppState);
}
render() {
console.debug('!!! App Rendering');
AppState.addEventListener('change', this._handleAppStateChange);
return <View></View>;
}
}