React Search Query String Helper
Adds additional methods to handle search query.
Install
npm
npm install --save react-search-query-string-helper
yarn
yarn add react-search-query-string-helper
Usage
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