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

v0.1.1

Published

Simple wrapper to use React Native Experimental Navigation

Downloads

9

Readme

reactNativeRouterSinux

Simple wrapper to use React Native Experimental Navigation

How to use it

The first step is to create an initial component that use NavigationRoot. This is in general the first component that your application will load. (index.ios.js or whatever you decide).

NavigationRoot is tacking a props named initialRoute that allow the router to display the first view.

EveryChildren is considered in the stack if they have a props named routeKey. It's the key we will use in order to navigate.


import { NavigationRoot } from 'react-native-router-sinux';

...

render() {
  return (
    <NavigationRoot initialRoute="home">
      <View routeKey="home">
        <Text> This is the home page</Text>
      </View>
      <View routeKey="first">
        <Text> This is the first page</Text>
      </View>
      <View routeKey="second">
        <Text> This is the second page</Text>
      </View>
    </NavigationRoot>
  )
}

Now we have our NavigationRoot setted we want to be able to navigate between views. For that we use navigationStore

navigationStore is a store writen in Sinux that duplicate the behavior of ExperimentalNavigation helper NavigationStateUtils.

Method available in NavigationStateUtils are accessible through navigationStore.

  * back: Sets the focused route to the previous route.
  * forward: Sets the focused route to the next route.
  * get: Gets a route by key
  * has: Returns `true` at which a given route's key can be found in the routes of the navigation state.
  * indexOf: Returns the first index at which a given route's key can be found in the routes of the navigation state, or -1 if it is not present.
  * jumpTo: Sets the focused route of the navigation state by key.
  * jumpToIndex: Sets the focused route of the navigation state by index.
  * **pop**: Pops out a route from the navigation state. *Note that this moves the index to the positon to where the last route in the stack is at.*
  * **push**: Pushes a new route into the navigation state. *Note that this moves the index to the positon to where the last route in the stack is at.*
  * replaceAt: Replace a route by a key.
  * replaceAtIndex: Replace a route by a index.
  * reset: Resets all routes. *Note that this moves the index to the positon to where the last route in the stack is at if the param `index` isn't provided.*

In order to navigate to a new view simply import navigationStore and call the push function.

import { navigationStore } from 'react-native-router-sinux';

...

navigationStore.push({ key: 'first' });

That's it.

In a same way to go back simply call pop function

navigationStore.pop();

You can pass all the props supported by the ExperimentalNavigation component NavigationCardStack but renderScene and navigationState :

{
  direction: NavigationGestureDirection ('horizontal' | 'vertical'),
  onNavigateBack?: Function,
  renderHeader: ?NavigationSceneRenderer,
  cardStyle?: any,
  style: any,
  gestureResponseDistance?: ?number,
}

This is a first shot, please don't hesitate to request support on Sinux or this component.