react-native-route-navigator
react-native Navigator with URI driven navigation facilitating simple transfer of data between components using query, and body parameters.
Quick start
Install the module:
npm install --save react-native-route-navigator
Add it you your application:
var React = ;var RouteNavigator Router = ; Component { return <RouteNavigator initialRouteStack='/page1/my-id-string' router=thisrouter app=this/> } { if !this_router this_router = ; this; return this_router; } { // Add our routes here router; router; } ReactAppRegistry;
RouteNavigator
This extends reacts Navigator class.
app
- Application reference to pass to all managed components.Router
- The composed router to use for route navigation.
Routes
name
- The name of the route.URI
- The route-parser URI.component
- Unconstructed React component class to use for the page.options
defaultAnimation
- The default animation to use if none are specific.props
- The props to construct the component with.useCache
- States if the component should persist when unmounted.
How To Navigate
The RouteNavigator will construct mounted components with app
and nav
. app
being the app
prop passed to the route navigator, and nav
being a reference to the Navigator component.
The nav object can be an object or a string.
Nav Object Components:
name
- The name or URI of the routeanimation
- The animation to use for the transitionprops
- Additional props to use for the controllerbody
- The body object to pass to the controller.
Example calls:
// Go back to previous controller in route stackthispropsnav; // Navigate By URIthispropsnav; // URI with Non Default Animationthispropsnav; // Navigate By Namethispropsnav;thispropsnav;
Reading Navigation Query/Body
You can receive URI parameters via this.state.query
and the body object via this.state.body
.