I am facing an issue with using query params and react router dom.
When I do an API call and it returns me a status 200, I redirect the user to the results page with a history.push. So far everything is working fine. However, when I am on the results page and refresh the page, I want to use the url with query params to perform a new search, unfortunately React Router Dom is not able to recognize the url and redirects me.
App.tsx
<PrivateRoute path="/search?value=:searchValue&type=:searchType">
<Dashboard />
</PrivateRoute>
<Route path="/redirection" component={RedirectionPage} />
<Redirect to="/login" />
Search.tsx
history.push({
pathname: `/search?${formattedSearch
.map((search) => `value=${search.value}&type=${search.type}`)
.toString()
.replace(",", "|")}`,
state: search
});
This history.push works great and redirects the user to the desired page.
But when I refresh the page with the same url, React Router Dom doesn't recognize the route and doesn't redirect me to the component.
Do you have any ideas ? Thank you and wish you a nice day.