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

@tableflip/react-native-navbar

v2.1.1

Published

Stateless NavBar navigation for React Native

Downloads

10

Readme

react-native-navbar dependencies Status

A stupidly simple "stateless", route based, navigation bar component built on top of React Native's Navigator, for use with Redux.

Getting started

npm install @tableflip/react-native-navbar

Example

import React, { Component } from 'react'
import { connect } from 'react-redux'
import NavBar from '@tableflip/react-native-navbar'
import { Home, Post } from './scenes'

const Routes = {
  '/': Home,
  '/post/:id': Post
}

class App extends Component {
  static defaultProps = { url: '/' }

  render () {
    return <NavBar routes={Routes} url={this.props.url} />
  }
}

export default connect(({ url }) => ({ url }))(App)
  1. Store the current URL in your Redux store
  2. Create a redux action for changing the URL
  3. Your scenes change the URL by dispatching your action

Conventions

  • URL params are passed to your scenes in a params prop
  • Your scenes specify the bar LeftButton, Title and RightButton components in a static property called navBar

URL params

Currently route URLs only support params defined as :paramName within a URL. Wildcards are currently not supported. When navigating to a URL, the params are extracted and passed to the scene in a params prop.

For example a route like /post/:id would result in an object like { id: 'some id' } being passed to your scene in a params prop.

These params are also passed to any navBar components (see below).

static navBar = { LeftButton, Title, RightButton }

Your scenes define what components should appear in the navigation bar when they are shown. All three properties are optional.

Your navBar components are passed any URL params in props.

Note: be careful when wrapping your component in a container, it can hide the navBar property from the NavBar component.

Passed props

The following properties are passed to route components and "navBar" components:

  • params - parameters from the URL
  • location - an object conceptually similar to document.location in web browsers
    • location.pathname - the path section of the URL, before the query, including the initial slash if present
    • location.search - the 'query string' portion of the URL, including the leading question mark
    • location.query - a querystring-parsed object
    • location.hash - the 'fragment' portion of the URL including the pound-sign

The following additional properties are passed to route components:

  • isFocusedRoute - whether or not this is the currently focused route (it won't be during transition in/out)

Props

routes

An object describing the routes available to the NavBar. Keys should be URLs and values should be React Components.

url

The URL that should currently be displayed. This can be a string, but will more commonly be an object, e.g.

// Slide in from the right
{ url: '/post/123', from: 'right' }
// Slide in from the left (looks like we're navigating "backwards")
{ url: '/', from: 'left' }
// Do not transition, display immediately
{ url: '/', from: 'none' }

showBar

Display a Navigator.NavigationBar at the top of the screen. This is true by default but can be disabled if your scenes need to take up the whole screen.

style, barStyle, sceneStyle

Styles passed to the container, bar and scene respectively.

sceneConfigLeft and sceneConfigRight

Configuration for scene transitions. Defaults to Navigator.SceneConfigs.HorizontalSwipeJumpFromLeft and Navigator.SceneConfigs.HorizontalSwipeJumpFromRight. Scene configuration options.


A (╯°□°)╯︵TABLEFLIP side project.