Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beanloop/react-with-params
React HOC for extracting router params.
https://github.com/beanloop/react-with-params
higher-order-component react-router react-router-v4
Last synced: about 2 months ago
JSON representation
React HOC for extracting router params.
- Host: GitHub
- URL: https://github.com/beanloop/react-with-params
- Owner: beanloop
- License: apache-2.0
- Created: 2017-03-15T14:05:01.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-04T19:44:26.000Z (over 6 years ago)
- Last Synced: 2024-10-12T01:17:54.409Z (4 months ago)
- Topics: higher-order-component, react-router, react-router-v4
- Language: TypeScript
- Homepage:
- Size: 99.6 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# react-with-params
[![Build Status](https://travis-ci.org/beanloop/react-with-params.svg?branch=master)](https://travis-ci.org/beanloop/react-with-params)
[![npm version](https://badge.fury.io/js/react-with-params.svg)](https://badge.fury.io/js/react-with-params)
[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)React HOC for extracting router params.
## Install
```
yarn add react-with-params
npm install --save react-with-params
```## Usage
```typescript
import Route from 'react-router/Route'
import {withParams} from 'react-with-params'const ShowName = withParams({params: 'name', match: '/user/:name'})(({name}) =>
{name}
)```
```typescript
import Route from 'react-router/Route'
import {withParams} from 'react-with-params'const ShowNameAndId = withParams({params: ['name', 'id'], match: '/user/:name/:id'})(({name, id}) =>
{id} - {name}
)```
### Query parameters
```typescript
import Route from 'react-router/Route'
import {withParams} from 'react-with-params'const Display = withParams({
queryParams: 'next',
match: '/users',
})(({next}) =>
{next}
)```
```typescript
import Route from 'react-router/Route'
import {withParams} from 'react-with-params'const Display = withParams({
queryParams: ['next', 'timestamp'],
match: '/users',
})(({next, timestamp}) =>
{next} - {timestamp}
)```
## License
react-with-params is dual-licensed under Apache 2.0 and MIT
terms.