Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit e3d60e2

Browse files
committed
Fix withNavigationFocus initial event by moving subscriptions to mount
1 parent 8b27afb commit e3d60e2

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/views/withNavigationFocus.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,18 @@ export default function withNavigationFocus(Component) {
1010
constructor(props) {
1111
super(props);
1212

13-
this.state = {
14-
isFocused: props.navigation ? props.navigation.isFocused() : false,
15-
};
16-
}
17-
18-
componentDidMount() {
19-
const { navigation } = this.props;
2013
this.subscriptions = [
21-
navigation.addListener('didFocus', () =>
14+
props.navigation.addListener('didFocus', () =>
2215
this.setState({ isFocused: true })
2316
),
24-
navigation.addListener('willBlur', () =>
17+
props.navigation.addListener('willBlur', () =>
2518
this.setState({ isFocused: false })
2619
),
2720
];
21+
22+
this.state = {
23+
isFocused: props.navigation ? props.navigation.isFocused() : false,
24+
};
2825
}
2926

3027
componentWillUnmount() {

0 commit comments

Comments
 (0)