0.1.0 • Published 7 years ago
@react-hero/router-view v0.1.0
@react-hero/router-view
Route configuration component for
react-router.
Installation
npm install @react-hero/router-view --save
# or
yarn add @react-hero/router-viewBasic Usage
import { Router } from 'react-router'
import { RouterView } from '@react-hero/form'
import { createHashHistory } from 'history'
const history = createHashHistory()
const routes = [
{
path: '/home',
component: () => <h2>Home</h2>
},
{
path: '/product',
component: () => <h2>Product</h2>
},
{
path: '/about',
component: () => <h2>About</h2>
}
]
function App() {
return (
<Router history={history}>
<div>
<h1>App</h1>
<RouterView routes={routes} />
</div>
</Router>
)
}APIs
Route Option
pathURL string.componentReact component.exactWhether only matches withlocation.pathnameexactly.redirectNavigates to new location.routesNested child routes.payloadPass as a prop into route component.
Route Component Props
Includes all props from react-router and the following props.
routesNested child routes from route option.payloadpayload from route option.
RouterView Props
switchedUseSwitchas the wrapped component, default totrue.routesNested child routes, come fromthis.props.extraPropsPass as extra props into child routes.
0.1.0
7 years ago
0.1.0-alpha.0
7 years ago