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

react-routing

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-routing

Isomorphic router for React.js applications

latest
Source
npmnpm
Version
0.0.7
Version published
Weekly downloads
45
-15.09%
Maintainers
1
Weekly downloads
 
Created
Source

Isomorphic router for React.js applications

NPM version NPM downloads Build Status Dependency Status Chat

For more information visit www.kriasoft.com/react-routing

How to Install

$ npm install react-routing --save

Quick Start

import React from 'react';
import ReactDOM from 'react-dom';
import Router from 'react-routing/lib/Router';
import NotFoundPage from './components/NotFoundPage';
import ErrorPage from './components/ErrorPage';

const router = new Router(on => {

  on('*', async (state, next) => {
    const Layout = require('./components/Layout');
    const component = await next();
    if (component === undefined) {
      return undefined;
    }
    return <Layout context={state.context}>{component}</Layout>;
  });

  on('/', () => {
    const HomePage = require('./components/HomePage');
    return <HomePage />;
  });

  on('/products', async () => {
    const [data, require] = await Promise.all([
      http.get('/api/products'),
      new Promise(resolve => require.ensure(['./components/ProductsPage'], resolve))
    ]);
    const ProductsPage = require('./components/ProductsPage');
    return data ? <ProductsPage products={data} /> : undefined;
  });

  on('/products/:name', async (state) => {
    const [data, require] = await Promise.all([
      http.get(`/api/products/${state.params.name}`),
      new Promise(resolve => require.ensure(['./components/ProductInfoPage'], resolve))
    ]);
    const ProductInfoPage = require('./components/ProductInfoPage');
    return data ? <ProductInfoPage product={data} /> : undefined;
  });

  on('error', (state, error) => state.statusCode === 404 ?
    <Layout context={state.context} error={error}><NotFoundPage /></Layout> :
    <Layout context={state.context} error={error}><ErrorPage /></Layout>
  );

});

await router.dispatch({ path: '/products/example' }, (state, component) => {
  ReactDOM.render(component, document.getElementById('app'));
});

Support

License

The MIT License © Konstantin Tarkus (@koistya)

Keywords

react

FAQs

Package last updated on 30 Dec 2015

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