router-add-query
Version:
React router with query params
52 lines (35 loc) • 1.26 kB
Markdown
[]
[](https://travis-ci.org/joemccann/dillinger)
This library will allow you to add query params to react router v4.0.0 and above.
- Add an object to the location props of any component with the most recent queryParams of each page visited :
```
{
query:
{ "/": {utm_source: "facebook"},
{ "signup/": {utm_campaign: "Dillinger", utm_source: "facebook"}}
}
```
- Lightweight
- Use indexdb to store the state of the queryParams
It uses a number of open source projects to work properly:
* [Ramda] - A practical functional library for JavaScript programmers.
* [idb-keyval] - A super-simple-small promise-based keyval store implemented with IndexedDB
And of course React-router-query-params itself is open source with a [MIT License][dill]
on GitHub.
```sh
$ yarn install react-router-query-params
```
For production environments...
```sh
import { withRouterWithQuery } from 'react-router-query-params';
const App = () => <div> Example Component </div>
withRouterWithQuery(App);
// OR
<RouterWithQuery> <App/> <RouterWithQuery/>
```
Want to contribute? Great!