1.0.0 • Published 5 years ago

react-router-static v1.0.0

Weekly downloads
20
License
MIT
Repository
github
Last release
5 years ago

React Router Static

A dead simple static router for React. Useful for multi-window Electron applications.

Install

npm install --save react-router-static

Usage

This router simply maps routes to components, and that's it.

The current route is the value of the current url's route query paremeter (ie. http://localhost?route=foo), if none is detected it's value will be default.

import * as React from 'react';
import {render} from 'react-dom';
import {Router} from 'react-router-static';
import Foo from './components/foo';
import Bar from './components/bar';
import Error404 from './components/error_404';

const routes = { // A map of "route" => "component"
  default: Error404, // Default component to mount when no other route is detected
  foo: Foo,
  bar: Bar
};

render (
  <Router routes={routes} />,
  document.getElementById ( 'app' )
);

License

MIT © Fabio Spampinato