Skip to content

sandeshshrestha/react-search-query-string-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Search Query String Helper

Adds additional methods to handle search query.

NPM JavaScript Style Guide

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

About

React Search Query String Helper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published