Do not create listeners on each focus

This commit is contained in:
Arnaud Vergnet 2020-04-08 12:32:08 +02:00
parent a54493a23f
commit 8e2d1c7a2b

View file

@ -68,6 +68,8 @@ class HomeScreen extends React.Component<Props> {
componentDidMount() { componentDidMount() {
this.props.navigation.addListener('focus', this.onScreenFocus); this.props.navigation.addListener('focus', this.onScreenFocus);
// Handle link open when home is focused
this.props.navigation.addListener('state', this.handleNavigationParams);
} }
onScreenFocus = () => { onScreenFocus = () => {
@ -77,8 +79,6 @@ class HomeScreen extends React.Component<Props> {
headerRight: this.getHeaderButton, headerRight: this.getHeaderButton,
}); });
} }
// Handle link open when home is focused
this.props.navigation.addListener('state', this.handleNavigationParams);
// handle link open when home is not focused or created // handle link open when home is not focused or created
this.handleNavigationParams(); this.handleNavigationParams();
}; };