fix: address breaking change in react-native for Linking

This commit is contained in:
Satyajit Sahoo
2021-02-21 15:45:49 +01:00
parent 5c7f892d77
commit fb1e8d4a07

View File

@@ -214,7 +214,7 @@ export default function createNavigationContainer(Component) {
}
}
_statefulContainerCount++;
Linking.addEventListener('url', this._handleOpenURL);
this._linkingSub = Linking.addEventListener('url', this._handleOpenURL);
// Pull out anything that can impact state
let parsedUrl = null;
@@ -331,7 +331,14 @@ export default function createNavigationContainer(Component) {
componentWillUnmount() {
this._isMounted = false;
Linking.removeEventListener('url', this._handleOpenURL);
// https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7
if (this._linkingSub?.remove) {
this._linkingSub?.remove();
} else {
Linking.removeEventListener('url', this._handleOpenURL);
}
this.subs && this.subs.remove();
if (this._isStateful()) {