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

feature-react-navigation

v1.0.0

Published

Feature based navigation using react-navigation

Downloads

3

Readme

= feature-react-navigation - Feature based navigation using react-navigation

feature-react-navigation is a https://feature-u.js.org/[feature-u] module which provide a routing aspect into your features using https://reactnavigation.org/[react-navigation].

The module aim to build a single navigation tree with routes provided by each feature registred in your feature-u instance. Your features don't have the knowledge off the final tree, they only have to expose their routes throught the route aspect.

image:https://travis-ci.org/sylvainlg/feature-react-navigation.svg?branch=master[title="TravisCI Status", link="https://travis-ci.com/sylvainlg/feature-react-navigation"] image:https://api.codacy.com/project/badge/Grade/508c8d7d913a4c3ca61b7428dea59bdb[title="Codacy Grade Badge",link="https://www.codacy.com/manual/sylvainlg/feature-react-navigation?utm_source=github.com&utm_medium=referral&utm_content=sylvainlg/feature-react-navigation&utm_campaign=Badge_Grade"] image:https://api.codacy.com/project/badge/Coverage/508c8d7d913a4c3ca61b7428dea59bdb[title="Codacy Coverage Badge",link="https://www.codacy.com/manual/sylvainlg/feature-react-navigation?utm_source=github.com&utm_medium=referral&utm_content=sylvainlg/feature-react-navigation&utm_campaign=Badge_Coverage"] image:https://img.shields.io/npm/v/feature-react-navigation.svg[title="NPM Version Badge",link="https://www.npmjs.com/package/feature-react-navigation"]

== Getting started

$ yarn add feature-react-navigation

Additionnally, you may need peerDependencies installed :

[source,bash]

$ yarn add feature-u $ yarn add @react-navigation/core $ yarn add @react-navigation/native or $ yarn add @react-navigation/web

== Usage

=== 1 - Register the aspect

Within your mainline, register the feature-react-navigation routeAspect to feature-u's https://feature-u.js.org/cur/api.html#launchApp[launchApp()] method.

Please note that routeAspect has 1 required named parameter (see below for details) :

  • <<Navigator configuration,Navigator>>

==== App.js

[source,js]

import { launchApp } from 'feature-u'; import { createRouteAspect } from 'feature-react-navigation'; import { createAppContainer } from '@react-navigation/native'; import features from './feature';

// configure Aspects (as needed) const routeAspect = createRouteAspect({ Navigator });

export default launchApp({

aspects: [ routeAspect, ... other Aspects here ],

features,

registerRootAppElm(rootAppElm) { AppRegistry.registerComponent(appName, () => () => rootAppElm); // convert rootAppElm to a React Component }, });

==== Navigator object configuration

This is the classic

With this configuration, the module stay a pure react module. Any adherence with react-native is no longer required.

==== navigationPattern configuration

In mobile application, the navigation stack could be a lot more complex than on the web and react-navigation respond to that complexity by providing some different navigators (https://reactnavigation.org/docs/en/stack-navigator.html[stack], https://reactnavigation.org/docs/en/switch-navigator.html[switch], https://reactnavigation.org/docs/en/bottom-tab-navigator.html[tab], https://reactnavigation.org/docs/en/drawer-navigator.html[drawer]). The navigationPattern configuration is the way to deal with it in feature-react-navigation.

Beside, features don't have to know how the navigation is organize in the final application. Even, you may want to re-use some feature across applications whithout inheriting the same navigation stack. With this way of building navigation stack, your application have total control about it.

  • navigator: create[Navigator] function
  • navigationOptions: options taken by the navigator function
  • routes: list of named route from features
  • featureRoutes: list of feature names, expended to each routes starting by the feature name - see <>.

[source,javascript]

const Navigator = ({ routes }) => { return ( <Stack.Navigator> {routes.map(route => <Stack.Screen name={route.screen.name} component={route.screen} />)} </Stack.Navigator> ) }

2 - Promote routes

Within each feature that promotes UI Screens, simply register the feature's route through the Feature.route property (using feature-u's [createFeature()]).

In the sample, login feature promotes somes routes in a react-navigation compatible format. It's strongly encouraged to prefix all route names by the feature name in order to use <<featureRoutes>> pattern configuration.

.src/feature/login/index.js [source,javascript]

import React from 'react'; import {createFeature} from 'feature-u';

import fname from './feature-name' import {LoginScreen, LoginSuccessScreen} from './screens';

export default createFeature({

name: 'login',

route: { routes: { [${fname}.LOGIN]: { screen: LoginScreen, }, [${fname}.SUCCESS]: { screen: LoginSuccessScreen, }, }, },

... snip snip });