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

@roman01la/react-native-router

v1.0.0

Published

Declarative router for React Native

Downloads

4

Readme

React Native Router

Installation

$ npm i @roman01la/react-native-router

Usage

Navigation structure

import { Router, Tab, Route } from '@roman01la/react-native-router';

const App = () => (
  <Router>
    <Tab key='home' initial>
      <Route key='profile' component={ProfileLayout} initial />
      <Route key='settings' component={SettingsLayout} />
    </Tab>
    <Tab key='search'>
      <Route key='search' component={SearchLayout} initial />
      <Route key='search_results' component={SearchResultsLayout} />
    </Tab>
  </Router>
);

Declarative navigation

import { Link } from '@roman01la/react-native-router';

// navigate within the same tab
<Link to={{ route: 'settings' }}>
  <Text>settings</Text>
</Link>

// navigate to another tab
<Link to={{ tab: 'search' }}>
  <Text>settings</Text>
</Link>

// navigate to specific route in another tab
<Link to={{ tab: 'search', route: 'search_results' }}>
  <Text>settings</Text>
</Link>

// navigate back
<Link back>
  <Text>settings</Text>
</Link>

Programmatic navigation

class MyComponent extends Component {
  static contextTypes = {
    navigate: PropTypes.func,
    back: PropTypes.func,
  }
  _navigateTo({ tab, route }) {
    this.context.navigate({ tab, route });
  }
  _goBack() {
    this.context.back();
  }
}

Tab Bar

import { Link } from '@roman01la/react-native-router';

const Tab = ({ children, active, ...props }) => (
  <Link style={active ? styles.activeTab : styles.tabBase} {...props}>
    {children}
  </Link>
);

class TabBar extends Component {
  static contextTypes = {
    currentTabIdx: PropTypes.number,
  }
  render() {

    const { currentTabIdx } = this.context;

    return (
      <View>

        <Tab active={currentTabIdx === 0} to={{ tab: 'home' }}>
          <Text>home</Text>
        </Tab>

        <Tab active={currentTabIdx === 1} to={{ tab: 'settings' }}>
          <Text>settings</Text>
        </Tab>

      </View>
    );
  }
}

Components

<Router />

Router component maintains navigation state and provides navigation API. It is built on top of NavigationExperimental.

<Tab />

Tab component should be used to group routes into tabs.

Props

  • key — name of the tab
  • initial — declare initial tab

<Route />

Route component should be used to declare a view routes.

Props

  • key — name of the route
  • component — component which should be rendered by the route
  • initial — declare initial route

<Link />

Link component should be used for navigation between routes and tabs.

Props

  • to — navigation target described as an object which consists of route and tab properties.
{
  route: 'routeKey',
  tab: 'tabKey'
}
  • back — go back in history

License

MIT