Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 88d074b

Browse files
author
Jeremy Greer
committed
pass route to willFocus and didFocus handlers instead of route.name
1 parent 59fb841 commit 88d074b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

‎README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ The functions **`this.props.setRightProps`**, **`this.props.setLeftProps`** and
165165

166166
As of 0.7.0 the router acts as a relay for events emitted by the navigator, and extends these to the following list:
167167

168-
- `willFocus`: Emitted when a route will focus. Passes {String} route name and {Object} route as args.
169-
- `didFocus`: Emitted when a route did focus. Passes {String} route name and {Object} route as args.
168+
- `willFocus`: Emitted when a route will focus. Emits route object.
169+
- `didFocus`: Emitted when a route did focus. Emits route object.
170170
- `willPop`: Emitted when a route stack will be popped. Triggered by `Navigator.pop();`
171171
- `didPop`: Emitted when a route stack did pop. Triggered by `Navigator.pop();`
172172
- `willPush`: Emitted when a new route will be pushed to the route stack. Emits the new route object. Triggered by `Navigator.push(route);`
@@ -181,9 +181,9 @@ As of 0.7.0 the router acts as a relay for events emitted by the navigator, and
181181
You can listen to these events by adding an event listener as such:
182182

183183
```javascript
184-
this.props.routeEmitter.addListener('didFocus', (name, route) => {
185-
//Do something with name or route...
186-
});
184+
this.props.routeEmitter.addListener('didFocus', (route) => {
185+
console.log(route.name, 'didFocus');
186+
});
187187
```
188188

189189
As of v0.8.0 the `leftCorner`, `rightCorner` and `titleComponent` have access to the following router functions :

‎index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ class Router extends React.Component {
8383
this.refs.navigator.navigationContext.addListener('willfocus', (event) => {
8484
const route = event.data.route;
8585
this.setState({ route });
86-
this.emitter.emit('willFocus', route.name,route);
86+
this.emitter.emit('willFocus', route);
8787
});
8888

8989
this.refs.navigator.navigationContext.addListener('didfocus', (event) => {
9090
const route = event.data.route;
91-
this.emitter.emit('didFocus', route.name,route);
91+
this.emitter.emit('didFocus', route);
9292
});
9393

9494
aspect.before(this.refs.navigator, 'pop', () => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /