The issue is that the withQueryString() method is not working as expected. To fix this, you can manually add the query string to the URL in the useEffect hook. Here's an updated code snippet:
const { filters, clients } = usePage().props
const [query, setQuery] = useState(filters.q)
useEffect(() => {
const queryString = new URLSearchParams({ q: query }).toString()
const url = `${window.location.pathname}?${queryString}`
return router.get(url, {}, { preserveState: true, replace: true })
}, [query])
// render the list:
clients.map()
This code creates a new URLSearchParams object with the q parameter set to the current search query. It then converts this object to a string and appends it to the current URL using window.location.pathname. This ensures that the correct URL is used when navigating between pages.
Note that you may need to adjust the URL construction depending on your specific routing setup.