How to pass params to history.push method in React Router?
To pass parameters to the history.push
method in React Router, you can use an object to specify the route to push to and include any parameters as properties of that object. For example:
this.props.history.push({pathname: '/template',search: '?name=sudheer',state: { detail: response.data },});
In the example above, the history.push
method is being used to push a new route onto the history stack, with the route specified as the pathname
property of the object passed to history.push
. The search
property of the object is used to specify query parameters for the route, and the state
property is used to specify state that should be associated with the route.
September 27, 2022
21995
Read more
What is React?
November 06, 2022
ReactJSHow to programmatically trigger click event in React?
November 06, 2022
ReactJS