Below push will redirect the URL to http://localhost:3000/search?category=furniture&city=San+Jose%2C+CA%2C+USA when I choose the furniture for the category and "San Jose, CA, USA" for the city.
this.props.history.push({
pathname: '/search',
search: "?" + new URLSearchParams({category: this.category, city: this.userCity}).toString()
});
In App.jsx, I defined a route like below:
<Route path="/search/:category?/:city?" component={props => <EventSearchPage {...props} />}/>
In the EventSearchPage
component, when I tried to access this.props.match.params
, I see both category and city are undefined
.
Can someone kindly let me know where went wrong? Thanks!