I have a bookmarks menu with search queries saved. Its a component with simple ‘react-router-dom’ Links.
How can I achieve that a search is triggered on navigating (selecting another bookmark)?
Hello,
can you explain better how you are doing it? Can you copy/paste one of the link?
Thanks for your reply.
You can reproduce with
import { Link } from 'react-router-dom';
<ul>
<li>
<Link to="/suche?q=Tomate">search for Tomate</Link>
</li>
<li>
<Link to="/suche?q=Gurke">search for Gurke</Link>
</li>
</ul>
If you navigate from one to the other, no search is triggered. But this is what I want: trigger search according the query params in the link target.
One of the 17 ways I walked so far is with searchOnUrlQueryStringChanged
which is called on window.onpopstate
(user goes back). But it is not exposed for external use.
Thanks for any hint!
It is again a bit hard to answer without a full understanding of what you are trying to achieve. It looks like that you are already in a React app, and that inside there is a search app (using React-SearchKit).
Assuming that it is the case, React-SearchKit manipulates and changes the URL params, but it does listen to changes done to the URL params: this to avoid an internal infinite loop.
We have implemented a way to notify React-SearchKit of external changes (e.g. when you manually change the URL params, as in your case), see here: you can notify the React-SearchKit app that something has changed and trigger a search.