0.2.0 • Published 7 years ago

react-with-params v0.2.0

Weekly downloads
8
License
MIT
Repository
github
Last release
7 years ago

react-with-params

Build Status npm version License

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.