Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

fabiospampinato/react-router-static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published