Skip to content

include route in args for willFocus/didFocus #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ The functions **`this.props.setRightProps`**, **`this.props.setLeftProps`** and

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

- `willFocus`: Emitted when a route will focus. Emits the route name as a string.
- `didFocus`: Emitted when a route did focus. Emits the route name as a string.
- `willFocus`: Emitted when a route will focus. Emits route object.
- `didFocus`: Emitted when a route did focus. Emits route object.
- `willPop`: Emitted when a route stack will be popped. Triggered by `Navigator.pop();`
- `didPop`: Emitted when a route stack did pop. Triggered by `Navigator.pop();`
- `willPush`: Emitted when a new route will be pushed to the route stack. Emits the new route object. Triggered by `Navigator.push(route);`
Expand All @@ -181,9 +181,9 @@ As of 0.7.0 the router acts as a relay for events emitted by the navigator, and
You can listen to these events by adding an event listener as such:

```javascript
this.props.routeEmitter.addListener('didFocus', (name) => {
//Do something with name..
});
this.props.routeEmitter.addListener('didFocus', (route) => {
console.log(route.name, 'didFocus');
});
```

As of v0.8.0 the `leftCorner`, `rightCorner` and `titleComponent` have access to the following router functions :
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ class Router extends React.Component {
this.refs.navigator.navigationContext.addListener('willfocus', (event) => {
const route = event.data.route;
this.setState({ route });
this.emitter.emit('willFocus', route.name);
this.emitter.emit('willFocus', route);
});

this.refs.navigator.navigationContext.addListener('didfocus', (event) => {
const route = event.data.route;
this.emitter.emit('didFocus', route.name);
this.emitter.emit('didFocus', route);
});

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