1.0.5 • Published 7 years ago
exmg-react-router v1.0.5
exmg-react-router
Hash based router for react.
Demo
TODO Check out the demo.
TODO Add animated example <div className={ match ? 'route-is-active' : '' }> ?
Install
npm install exmg-react-routeryarn add exmg-react-routerUsage
Example
import React from 'react';
import ReactDOM from 'react-dom';
import { RouterProvider, Route, Link } from 'exmg-react-router';
ReactDOM.render(
<RouterProvider>
<div className="body">
<Route path="/" exact>
<h1>Home</h1>
</Route>
<Route path="/hello/:name">
{ (match, params) => (match && <h1>Hello { params.name }</h1>) }
</Route>
</div>
<footer>
<Link to="/">Home</Link>
<Link to="/hello/World!">Hello World</Link>
</footer>
</RouterProvider>,
document.getElementById('app')
);Example sub routes
import React from 'react';
import ReactDOM from 'react-dom';
import { RouterProvider, Route, Link } from 'exmg-react-router';
ReactDOM.render(
<RouterProvider>
<div className="body">
<Route path="/" exact>
<h1>Home</h1>
</Route>
<Route path="/foo">
{ /* Routes will inherit path, so absolute path will be /foo */ }
<Route path="/" exact>
<h1>Foo /</h1>
</Route>
{ /* And /foo/bar */ }
<Route path="/bar" exact>
<h1>Foo /bar</h1>
</Route>
{ /* Links have absolute path */ }
<Link to="/foo">
Foo /
</Link>
<Link to="/foo/bar">
Foo /bar
</Link>
</Route>
</div>
<footer>
<Link to="/">Home</Link>
<Link to="/foo">Hello World</Link>
</footer>
</RouterProvider>,
document.getElementById('app')
);Props
RouterProvider
type: ?Stringdefault 'hash'. Optionsbrowser,hashormemory
Route
children: ?JSX.Element.exact: ?Booleandefaultfalse.exclude: ?Booleandefaultfalse. Exclude component from notFound match.notFound: ?Booleandefaultfalse.path: String. When<Route />is nested, path props of parent route will be automagically be prepended.
Link
activeClassName: ?Stringdefault'is-active'children: ?JSX.ElementdefaultnullclassName: ?Stringdefault'link'exact: ?BooleandefaultfalseonClick: ?Function.replace: ?Booleandefaultfalseto: String
2.0.0-alpha.3
7 years ago
2.0.0-alpha.2
7 years ago
2.0.0-alpha.1
7 years ago
2.0.0-alpha.0
7 years ago
2.0.0-3
7 years ago
2.0.0-2
7 years ago
2.0.0-1
7 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago