@ionx/react-routing
v0.1.4
Published
Simple page router for React with minimal dependencies
Downloads
2
Readme
React Routing
Simple page router for React with minimal dependencies
Install
npm install --save @ionx/react-routing
Basic Usage
Simple usage without redux:
import React from 'react'
import { render } from 'react-dom'
import { Router } from 'react-routing'
const Page1 = props => <h1>Page 1</h1>
const Page2 = props => <h1>Page 2</h1>
const App = (
<Router routes={{
'/uno': Page1,
'/dos': Page2,
'': '/uno' // Default handler redirects to /uno
}} />
)
render(App, document.getElementById('root'))
It is recommended to use React-Routing with redux, in which case the LocationReducer should be registered with createStore
, and the funcion bindHistory(store)
should be called after the store is created.
For a complete example using Redux, see the example
folder.
License
MIT © PowerOfM