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

@blueeast/bluerain-plugin-react-router

v1.1.5

Published

A BlueRain Plugin that adds cross platform routing via react-router v4

Downloads

9

Readme

React Router

React Router V4 and Redux integration.

Internally, uses react-router-dom for browser based apps and react-router-native for react native apps. Moreover, re-exports both packages on their respective platforms.

Usage

Run the following command in the plugin directoy:

npm i --save @blueeast/bluerain-plugin-react-router

Then in your boot function, pass the plugin like this:

import BR from '@blueeast/bluerain-os';
import ReactRouterPlugin from '@blueeast/bluerain-plugin-react-router';

BR.boot({
    plugins: [ReactRouterPlugin]
})

Components

This plugin registers following components in the Component registry, so they can be reused later by other apps and plugins:

Link

React Router's Link component.

More Info: Web, Native

Route

React Router's Route component.

More Info: Web, Native

RouterSwitch

React Router's Switch component.

More Info: Web, Native

Redirect

React Router's Redirect component.

More Info: Web, Native

RouterActions

This component follows the render prop pattern to provide router actions. These actions can be used to navigate between routes.

<BR.Components.RouterActions>
  {({ go, goBack, goForward, push, replace }) => {
    // use the param actions to navigate routes
    push('/some-path');
  }}
</BR.Components.RouterActions>

RouterConsumer

This component follows the render prop pattern to provide the following:

<BR.Components.RouterConsumer>
  {({ match, location, history }) => {
    console.log(location.pathname);
  }}
</BR.Components.RouterConsumer>

Hooks

This plugin provides complete flexibility to modify the react router configuration. This is done by providing various filter hooks at different stages of router initialization.

bluerain.system.app

This hook gives the ability to modify the main System App component that gets wrapped in react-router-redux's ConnectedRouter.

Parameters:

| Name | Type | Description | | --------- | --------------- | ------------------------------ | | SystemApp | React.Component | The main system app component. |

Returns:

| Name | Type | Description | | --------- | --------------- | ------------------------------ | | SystemApp | React.Component | The main system app component. |

Example:

This example wraps the System App with a ConnectedRouter provider by using a withReactRouter higher order component (HOC).

import BR from '@blueeast/bluerain-os';
import withReactRouter from './withReactRouter';
BR.Filters.add('bluerain.system.app',  (
            App: typeof React.Component
        ) =>{
            return withReactRouter(App, client);
        });
    }

router.config

Any plugin/app can add this hook to modify router plugin configs.

bluerain.redux.reducers.bluerain

This hook gives the ability to modify the nested bluerain reducer. This plugin adds incoming reducers into routerReducer from react-router-redux using this hook.

Parameters:

| Name | Type | Description | | -------- | ------ | ------------------------------------------------------------------------------------------------------------------- | | reducers | Object | The reducer object. This object will be sent as a param to the combineReducers of Redux after callback execution. |

Returns:

| Name | Type | Description | | -------- | ------ | ------------------------------------------------------------------------------------------------------------------- | | reducers | Object | The reducer object. This object will be sent as a param to the combineReducers of Redux after callback execution. |

bluerain.redux.middlewares

This hook gives the ability to add or modify custom middlewares to the main redux store.

Parameters:

| Name | Type | Description | | ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------- | | middlewares | Array | This is an array of redux middlewares. This array will be sent as a param to the applyMiddleware of Redux after callback execution. |

Returns:

| Name | Type | Description | | ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------- | | middlewares | Array | This is an array of redux middlewares. This array will be sent as a param to the applyMiddleware of Redux after callback execution. |

Example:

This example adds a taskbar reducer to bluerain state, which will be accessible at bluerain.taskbar.

import BR from '@blueeast/bluerain-os';
import customMiddleware from './customMiddleware';

BR.Filters(
  'bluerain.redux.middlewares',
  function AddMiddleware(middlewares) {
    return middlewares.push(customMiddleware());
  }
);

API

ReactRouterPluginConfigs

This is the default configuration set that is used at boot time.

Properties

  • androidBackButton boolean [default: true] Listen for Android Back button on React Native. Details
  • deepLinking boolean [default: false] Enable deep linking on react native. Details
  • forceMemoryHistory boolean [default: false] Force plugin to use memory history
  • historyConfigs object Configs object passed to the history constructor.

ReactRouterPlugin

Extends Plugin

React Router (v4) plugin to add routing capabilities to BlueRain Apps.

Properties