Passing request parameters during program navigation in the response router
History objects can be used programmatically to change the current location using history.push and history.replace.
history.push('/home?the=query', { some: 'state' })
If we pass the story object to the component as a property. Then we can programmatically program using the router's response methods available in the history object.
Now suppose you are passing a history object as an alert called a βrouterβ. Therefore, it will refer within the component with class-based syntax, for example:
this.props.router
When using push or replace, you can specify both the URL path and the state as separate arguments, or include everything in one location-like object as the first argument.
this.props.router.push('/some/path?the=query')
Or you can use a single location-like object to specify both the URL and the state. This is equivalent to the example above.
this.props.router.push({ pathname: '/some/path', //path search: '?the=query' // query param named 'search' })
Note. Of course, make sure that this.props.router is actually a history object from the agent-router api.
source share