An open-source entry in TopGit's GitHub warehouse: t4t5/react-native-router, 1.2k stars, JavaScript. Awesome navigation for your React Native app.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
NOTE: This project is deprecated. Please use React Navigation instead!
Legacy instructions:
Install
Make sure that you are in your React Native project directory and run:
npm install react-native-router --save
Usage
var Router = require('react-native-router');
The basics:
// The initial page
var HelloPage = React.createClass({
render: function() {
return <Text>Hello world!</Text>;
}
});
// Your route object should contain at least:
// - The name of the route (which will become the navigation bar title)
// - The component object for the page to render
var firstRoute = {
name: 'Welcome!',
component: HelloPage
};
// The Router wrapper
var MyApp = React.createClass({
render() {
return (
<Router firstRoute={firstRoute} />
)
}
});
AppRegistry.registerComponent('routerTest', () => MyApp);
Boom. That's it.
From the "Hello world!"-page you can then navigate further to a new component by calling this.props.toRoute(). Let's build upon the HelloPage component in our first example:
Now, when you click on "Next page please!", it will go to the next page (which in this case is still HelloPage but with a new title). Keep in mind that this.props.toRoute() needs to be called from one of the top-level routes, therefore, if your link is deeply nested within multiple components, you need to make sure that the action "bubbles up" until it reaches the parent route, which in turn calls this.props.toRoute().
A more advanced example: Twitter app
To see more of the router in action, you can check out the Twitter example app that comes with the package. Just make sure that you first drag all the images from node_modules/react-native-router/twitter-example/images to your project's Images.xcassets:
After that, don't forget to rebuild the app in XCode before you launch the simulator. Then test the app by requiring the TwitterApp component:
var TwitterApp = require('./node_modules/react-native-router/twitter-example');
var {
AppRegistry
} = React;
AppRegistry.registerComponent('routerTest', () => TwitterApp);
Configurations
The <Router \> object used to initialize the navigation can take the following props:
firstRoute (required): A React class corresponding to the first page of your navigation
headerStyle: Apply a StyleSheet to the navigation bar. You'll probably want to change the backgroundColor for example.
titleStyle: Apply a StyleSheet to the navigation bar titles. Useful for changing the font or text color.
backButtonComponent: By default, the navigation bar will display a simple "Back" text for the back button. To change this, you can specify your own backButton component (like in the Twitter app).
rightCorner: If you have the same occuring action buttons on the right side of your navigation bar (like the Twitter "Compose"-button), you can specify a component for that view.
customAction: A special callback prop for your action buttons (this can be handy for triggering a side menu for example). The action gets triggered from your custom leftCorner or rightCorner components by calling this.props.customAction("someActionName") from them. It is then picked up like this: <Router customAction={this.doSomething} />.
The this.props.toRoute() callback prop takes one parameter (a JavaScript object) which can have the following keys:
name: The name of your route, which will be shown as the title of the navigation bar unless it is changed.
component (required): The React class corresponding to the view you want to render.
leftCorner: Specify a component to render on the left side of the navigation bar (like the "Add people"-button on the first page of the Twitter app)
rightCorner: Specify a component to render on the right side of the navigation bar
titleComponent: Specify a component to replace the title. This could for example be your logo (as in the first page of the Instagram app)
headerStyle: change the style of your header for the new route. You could for example specify a new backgroundColor and the router will automatically make a nice transition from one color to the other!
data: Send custom data to your route.
Todos
When swiping from left to right to go back, it would be nice if the navigation bar's opacity gradually changed with the user's finger position. (See Issue #1)
Questions?
If something is unclear or if you just want to say hi, feel free to follow me on Twitter!
Does t4t5/react-native-router have a project website?
No homepage URL was recorded for t4t5/react-native-router in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
Does t4t5/react-native-router have any tags?
TopGit's last sync did not record any GitHub topics for t4t5/react-native-router. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on t4t5/react-native-router?
The most recent commit recorded on t4t5/react-native-router was 8.3 years ago, based on the GitHub push timestamp. The repository has 153 forks — one of the better signals of community interest.
Is t4t5/react-native-router open source?
Yes — t4t5/react-native-router ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/t4t5/react-native-router.
What license does t4t5/react-native-router use?
t4t5/react-native-router is released under the MIT license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where do I read more about t4t5/react-native-router?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/t4t5/react-native-router is the definitive source.
Read full README in the tab above.
Still deciding about react-native-router?
One click hands the question to an AI along with this page — see what it says about react-native-router.