New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@nuento/mobx-react-router

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuento/mobx-react-router

Simple react router with mobx state management

latest
Source
npmnpm
Version
1.2.7
Version published
Maintainers
1
Created
Source

mobx-react-router

Travis npm package Coveralls

A simple react router using mobx as state management

RouterStore

import RouterStore and add it the provider from mobx-react

import { Provider } from 'mobx-react';
import { RouterStore } from '@nuento/mobx-react-router';
import App from './App';

render(
  <Provider routerStore={new RouterStore()}>
    <App/>
  </Provider>,
  document.getElementById('root'),
);

Route

import { Route } from '@nuento/mobx-react-router';

<Route exact path="/" component={HomePage}/>
<Route path="/about" component={AboutPage}/>
<Route state-modal="signin" render={({match}) => {
  return <div>SignInModal</div>
}}/>
PropTypeDefault ValueDescription
pathstringnulldescribe a ExpressJS like path to match against.
exactboolfalserequire path to be an exact match
state-*string, numbernullmatch against specific key and value in the state.
renderfuncnullpass a function to be rendered on match
componentelementnullpass a react component to be rendered on match.
import { Link } from '@nuento/mobx-react-router';

<Link to="/">Home</Link>
<Link replace to="/about">About</Link>
<Link tag="button" state-modal="signin">Sign In</Link>
PropTypeDefault ValueDescription
tostringnulldescribe a ExpressJS like path to match against.
state-*string, numbernullmatch against specific key and value in the state.
tagelementapass an element to act as the link component
replaceboolfalsereplace history instead of pushing

Switch

Only the first route match in the switch will be rendered, if nothing is matched the last element will be rendered.

import { Switch, Route } from '@nuento/mobx-react-router';

<Switch>
    <Route exact path="/" component={HomePage}/>
    <Route path="/about" component={AboutPage}/>
    <Route state-modal="signin" render={({match}) => {
      return <div>SignInModal</div>
    }}/>
</Switch>
PropTypeDefault ValueDescription
definedboolfalseset to true if you you dont want it to render last route if no match

Keywords

react-component

FAQs

Package last updated on 16 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts