react-with-params
v0.2.0
Published
React HOC for extracting router params
Downloads
9
Readme
react-with-params
React HOC for extracting router params.
Install
yarn add react-with-params
npm install --save react-with-params
Usage
import Route from 'react-router/Route'
import {withParams} from 'react-with-params'
const ShowName = withParams('name', {match: '/user/:name'})(({name}) =>
<span>{name}</span>
)
<Route exact path='/user/:name' component={ShowName} />
import Route from 'react-router/Route'
import {withParams} from 'react-with-params'
const ShowNameAndId = withParams(['name', 'id'], {match: '/user/:name/:id'})(({name, id}) =>
<span>{id} - {name}</span>
)
<Route exact path='/user/:name/:id' component={ShowNameAndId} />
License
react-with-params is dual-licensed under Apache 2.0 and MIT terms.