react-search-query-string-helper
Advanced tools
Comparing version 0.0.1 to 0.0.3
{ | ||
"name": "react-search-query-string-helper", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"description": "React Search Query String Helper", | ||
@@ -13,11 +13,7 @@ "author": "sandeshshrestha", | ||
}, | ||
"scripts": { | ||
}, | ||
"scripts": {}, | ||
"peerDependencies": { | ||
"react-router-dom": "^4.3.0", | ||
"lodash": "^4.17.0", | ||
"query-string": "^6.4.2" | ||
"react-router-dom": "^4.3.0" | ||
}, | ||
"devDependencies": { | ||
}, | ||
"devDependencies": {}, | ||
"files": [ | ||
@@ -27,3 +23,6 @@ "src" | ||
"dependencies": { | ||
"lodash.clonedeep": "^4.5.0", | ||
"lodash.isobject": "^3.0.2", | ||
"query-string": "^6.5.0" | ||
} | ||
} |
# React Search Query String Helper | ||
Adds additional methods to handle search query. | ||
[![NPM](https://img.shields.io/npm/v/react-search-query-string-helper.svg)](https://www.npmjs.com/package/react-search-query-string-helper) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) | ||
## Install | ||
### npm | ||
```bash | ||
npm install --save react-search-query-string-helper | ||
``` | ||
### yarn | ||
```bash | ||
yarn add react-search-query-string-helper | ||
``` | ||
## Usage | ||
```jsx | ||
import React, { Component } from 'react'; | ||
import withSearchHelper from 'react-search-query-string-helper'; | ||
class MyComponent extends Component { | ||
render() { | ||
const search = JSON.stringify(this.parseSearch()); | ||
return ( | ||
<p>{search}</p> | ||
); | ||
} | ||
} | ||
export default withSearchHelper(MyComponent); | ||
``` | ||
## Added Methods | ||
* parseSearch() - Returns parsed search object | ||
* replaceSearch(search [String]) - Call history.replace with supplied search string | ||
* updateSearch(search [Object]) - Convert supplied search object into query string and call *replaceSearch()* | ||
* addSearch(search [Object]) - Add supplied search object with existing search query | ||
* removeSearch(keys [Array]) - Remove all keys from existing search query | ||
* clearSearch() - Clear search query | ||
MIT © [sandeshshrestha](https://github.com/sandeshshrestha) |
import { withRouter } from 'react-router-dom'; | ||
import queryString from 'query-string'; | ||
import { isObject, isArray, cloneDeep } from 'lodash'; | ||
import isObject from 'lodash.isobject'; | ||
import cloneDeep from 'lodash.clonedeep'; | ||
@@ -43,3 +44,3 @@ const cacheSearch = {}; | ||
// Stringify the value if it is object or array | ||
if (isObject(val) || isArray(val)) { | ||
if (isObject(val) || Array.isArray(val)) { | ||
val = JSON.stringify(val); | ||
@@ -46,0 +47,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4347
80
46
4
+ Addedlodash.clonedeep@^4.5.0
+ Addedlodash.isobject@^3.0.2
+ Addedquery-string@^6.5.0
+ Addedlodash.clonedeep@4.5.0(transitive)
+ Addedlodash.isobject@3.0.2(transitive)
- Removedlodash@4.17.21(transitive)