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-universal-router

v1.0.2

Published

React-Native router for Ios, Android and UWP

Downloads

21

Readme

React Native Universal Router

This is a alpha stage routing library for react-native and as such the syntax may change with releases.

At the time when we started building the only way to really do routing in react-native with UWP apps was to use react-native's own navigator.

This is a friendlier way, that uses similar syntax to more conventional react routers.

Support

We support UWP, Ios and Android, its important to note this should not be considered when routing for a website when using standard React as it does not utilise the browsers own history.

Installation

Using npm:

$ npm install --save react-native-universal-router

Then used with a module bundler such as webpack and an ES6 transpiler such as babel:

import { Router, Route } from 'react-native-universal-router';

Usage

    import React, { PureComponent } from 'react';
    import {
        Router,
        Route
    } from 'react-native-universal-router';

    export class App extends PureComponent {
        render() {
            return (
                <Router initialRoute={'/'}>
                    <Route path="/" routeComponent={InitialPage} />
                    <Route path="/about" routeComponent={AboutPage} />
                </Router>
            )
        }
    }

How it works

History

A prop called routerActions is passed into the routeComponent.

Should you want to go to the next page simply:

   routeComponent.goToRoute('/about');

This will redirect users to the about page. Likewise:

   routeComponent.goBack();

Will redirect users back one page.

Routes

First you need to add the router component, this just takes one prop. The initialRoute as a string.

Next each route is defined as a component that takes two props.

It is important that the path name is unique and at this stage can be any value. I have left it as a path name for clearness, but in theory can be any unique value.

The second prop is the component, this should normally be a page wide component and it will only be rendered when the relevant scene is in focus.

Where is this library going?

Before this library get's taken out of alpha/beta:

  • It will be fully tested.
  • It will have a default path such as '*'.
  • It will pass the path and any query params down to the page as props.
  • It will be adding animations when changing pages, so the new page will slide in.

If there are any feature requests that could be implemented into this library, please raise them as github issues