Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ that you're on with the new route that you pass it, and empties the navigation s

The **`this.props.popToRoute`** function takes in an object that can contain the same keys as `toRoute()`. The difference is that instead of adding a route to your stack, it pop all routes until the desired one.

The **`this.props.getCurrentRoutes()`** returns the current list of routes (same as [ReactNative Navigator getCurrentRoutes(0)]( https://facebook.github.io/react-native/docs/navigator.html#getcurrentroutes) ). This can be used as an argument for `popToRoute()`.

The functions **`this.props.setRightProps`**, **`this.props.setLeftProps`** and **`this.props.setTitleProps`** take in an object of props and sends that to your navbar's `RightComponent`, `LeftComponent` or `TitleComponent`, respectively.
- This allows you to talk directly to your navbar, because previously you could only talk to it when navigating forward or backward.

Expand Down
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ class Router extends React.Component {
setTitleProps(props) {
this.setState({ titleProps: props });
}

getCurrentRoutes() {
return this.refs.navigator.getCurrentRoutes();
}
customAction(opts) {
this.props.customAction(opts);
}
Expand Down Expand Up @@ -285,6 +287,11 @@ class Router extends React.Component {
this.setState({ titleProps: props });
};

const getCurrentRoutes = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected block statement surrounding arrow body. (arrow-body-style)

const routes = this.refs.navigator.getCurrentRoutes();
return routes;
};

const customAction = (opts) => {
this.props.customAction(opts);
};
Expand Down Expand Up @@ -315,6 +322,7 @@ class Router extends React.Component {
this.setRightProps = setRightProps;
this.setLeftProps = setLeftProps;
this.setTitleProps = setTitleProps;
this.getCurrentRoutes = getCurrentRoutes;
this.customAction = customAction;

return (
Expand All @@ -335,6 +343,7 @@ class Router extends React.Component {
setRightProps={setRightProps}
setLeftProps={setLeftProps}
setTitleProps={setTitleProps}
getCurrentRoutes={getCurrentRoutes}
customAction={customAction}
{...route.passProps}
/>
Expand Down