const navigate = useNavigate();
navigate('/other-page', { state: { id: 7, color: 'green' } });
const {state} = useLocation();
const { id, color } = state; // Read values passed on state
props.history.push('/other-page', { id: 7, color: 'green' }))
Then, you can access the state data in '/other-page' via:
props.location.state
<Route path="/" component={() => <Search name={this.props.name} />} />
<Route path="/:name" component={Search} />
<Route path="/" render={() => <Search name={this.props.name} />} />
render={routeProps => <Search name={this.props.name} {...routeProps} />}