How to pass params to history.push method in React Router v4?

  • Pass a string with the route path and query parameters
  • Pass an object with a "params" property
  • Pass an object with a "query" property
  • Pass an object with a "state" property
In React Router v4, you can pass params to the history.push method by using the "state" property of the location object. This property can contain any data that you want to pass along with the route, such as query parameters, form data, or session information. For example: this.props.history.push({ pathname: '/new-route', state: { foo: 'bar' } });.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *