Skip to content

Commit 5f5738b

Browse files
committed
Fixing #30
1 parent 899f7dd commit 5f5738b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ class Router extends React.Component {
5656
this.emitter = new EventEmitter();
5757
}
5858

59+
componentDidMount() {
60+
this.refs.navigator.navigationContext.addListener('willfocus', (event) => {
61+
const route = event.data.route;
62+
this.setState({ route });
63+
this.emitter.emit('willFocus', route.name);
64+
});
65+
66+
this.refs.navigator.navigationContext.addListener('didfocus', (event) => {
67+
const route = event.data.route;
68+
this.emitter.emit('didFocus', route.name);
69+
});
70+
}
71+
5972
onWillFocus(route) {
6073
this.setState({ route });
6174
this.emitter.emit('willFocus', route.name);
@@ -228,8 +241,6 @@ class Router extends React.Component {
228241
initialRoute={this.props.firstRoute}
229242
navigationBar={navigationBar}
230243
renderScene={this.renderScene}
231-
onDidFocus={this.onDidFocus}
232-
onWillFocus={this.onWillFocus}
233244
configureScene={this.configureScene}
234245
/>
235246
);

0 commit comments

Comments
 (0)