Query Strings with React Router

Query Strings with React Router

In this post will explain how to implement and parse query strings with React Router.

Credit to Caspoi.com

One of the easiest way to get query strings with react router is query-string’ Package.

Parse and stringify URL query strings

How to use query-string ?

import queryString from 'query-string'
componentDidMount() {
  const values = queryString.parse(this.props.location.search)
  console.log(values.filter) // "top"
  console.log(values.origin) // "im"

Check out query-string for more examples and detail information.

Happy Coding 🙂