aksonov / aksonov/react-native-router-flux
Replace deprecated Linking.removeEventListener(), to remove() , throwing error undefined is not a function
- 主要言語
- JavaScript
- スター
- 8.9k
- フォーク
- 2.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used [patch-package](https://github.com/ds300/patch-package) to patch `react-native-router-flux@4.3.1` for the project I'm working on.
Here is the diff that solved my problem:
```diff
diff --git a/node_modules/react-native-router-flux/src/Router.js b/node_modules/react-native-router-flux/src/Router.js
index 6f595e4..c9baf20 100644
--- a/node_modules/react-native-router-flux/src/Router.js
+++ b/node_modules/react-native-router-flux/src/Router.js
@@ -6,6 +6,8 @@ import defaultStore from './defaultStore';
import pathParser from './pathParser';
class App extends React.Component {
+ hardwareBackPressSubscriber ;
+ urlSubscriber;
static propTypes = {
navigator: PropTypes.func,
backAndroidHandler: PropTypes.func,
@@ -22,17 +24,17 @@ class App extends React.Component {
};
componentDidMount() {
- BackHandler.addEventListener('hardwareBackPress', this.props.backAndroidHandler || this.onBackPress);
+ this.hardwareBackPressSubscriber = BackHandler.addEventListener('hardwareBackPress', this.props.backAndroidHandler || this.onBackPress);
// If the app was "woken up" by an external route.
Linking.getInitialURL().then(url => this.parseDeepURL(url));
// Add an event listener for further deep linking.
- Linking.addEventListener('url', this.handleDeepURL);
+ this.urlSubscriber = Linking.addEventListener('url', this.handleDeepURL);
}
componentWillUnmount() {
- BackHandler.removeEventListener('hardwareBackPress', this.props.backAndroidHandler || this.onBackPress);
- Linking.removeEventListener('url', this.handleDeepURL);
+ this.hardwareBackPressSubscriber.remove();
+ this.urlSubscriber.remove();
}
onBackPress = () => this.props.navigationStore.pop();
```
This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).
コントリビューションガイド
評価
この issue はまだ評価されていません。