Skip to content

Commit e7703eb

Browse files
committed
Merge branch 'master' into examples/Explorer
2 parents ea108de + 5f0f80f commit e7703eb

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ React Native Simple Router
33

44
Awesome navigation for your React Native app.
55

6-
![NavBar Example](https://camo.githubusercontent.com/1e8083920215b01ed81fcd054dd01fe709e16a85/687474703a2f2f7472697374616e656477617264732e6d652f752f72656163742d6e61746976652d726f757465722f6e61746976652d726f757465722e676966)
6+
![NavBar Example](http://i.imgur.com/h5jUDC8.png)
77

88
Install
99
-------
@@ -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. Emits the route name as a string.
169-
- `didFocus`: Emitted when a route did focus. Emits the route name as a string.
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) => {
185-
//Do something with name..
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 :

components/NavBarContent.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ class NavBarContent extends React.Component {
173173
);
174174
} else if (this.props.route.index > 0) {
175175
leftCornerContent = (
176-
<NavButton onPress={this.goBack} backButtonComponent={this.props.backButtonComponent} />
176+
<NavButton onPress={this.goBack } backButtonComponent={ () => {
177+
const BackButton = this.props.backButtonComponent;
178+
const backButtonProps = this.props.route.backButtonProps || {};
179+
return <BackButton {...backButtonProps} />;
180+
}} />
177181
);
178182
}
179183

@@ -205,7 +209,7 @@ class NavBarContent extends React.Component {
205209
);
206210
}
207211

208-
if (Platform.OS === 'ios' || this.props.route.rightCorner || this.props.rightCorner) {
212+
if (Platform.OS === 'ios' || this.props.route.rightCorner || this.props.route.index > 0) {
209213
rightCorner = (
210214
<View style={[styles.corner, styles.alignRight]}>
211215
{rightCornerContent}

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);
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);
91+
this.emitter.emit('didFocus', route);
9292
});
9393

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

0 commit comments

Comments
 (0)