react get history search value code example

Example 1: history push search params

this.props.history.push({
    pathname: '/client',
    search: "?" + new URLSearchParams({clientId: clientId}).toString()
})

Example 2: use history in react router

import {createBrowserHistory} from 'history';import {useRouterHistory, Router, Route} from 'react-router';const history = useRouterHistory(createBrowserHistory)({  basename: '/basename'});history.listen(location => {  history.push('/super/url');});const router = (  <Router history={history}>    <Route path=/' component={App}></Route>  </Router>);