npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-route-navigator

v1.0.2

Published

React-Native page navigation using URIs.

Downloads

6

Readme

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 = require('React');
var { RouteNavigator, Router } = require('react-native-route-navigator');

class DemoApp extends React.Component {
	render() {
		return <RouteNavigator initialRouteStack={['/page1/my-id-string']]}
                            			   router={this.router}
				                              app={this}/>
	}
	
	get router() {
		if ( !this._router ) {
	    	this._router = new Router();
     		this.addRoutes(this._router);
    	}
	    return this._router;
	}
	
	addRoutes(router) {
		// Add our routes here
    	router.addRoute( 'page1', '/page1/:id', Page1, {
      		defaultAnimation: Navigator.SceneConfigs.FadeAndroid,
    	});
    	router.addRoute( 'page2', '/page2/', Page2, {
      		defaultAnimation: Navigator.SceneConfigs.FadeAndroid,
	      	props: {
	      		name: 'joe',
        		didPressButton: () => alert('Action from my app!')
      		}
    	});
    }
}

React.AppRegistry.registerComponent('DemoApp',  () => DemoApp);

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 route
  • animation - The animation to use for the transition
  • props - Additional props to use for the controller
  • body - The body object to pass to the controller.

Example calls:

// Go back to previous controller in route stack
this.props.nav.pop();

// Navigate By URI
this.props.nav.push('/page1/123');

// URI with Non Default Animation
this.props.nav.push({ 
	name: '/page1/123',
	animation: Navigator.SceneConfigs.FadeAndroid,
	props: {
		isRed: true
	},
	body: {
		cakeIs: 'lie'
	}
});

// Navigate By Name
this.props.nav.push('page1');
this.props.nav.push({ name: 'page1'});

Reading Navigation Query/Body

You can receive URI parameters via this.state.query and the body object via this.state.body.