Hi folks! New to remix at work, we've started using it a few weeks ago (remix 2), so still reading and re-reading the docs.
One thing I'm struggling to fully wrap my head around is how best to use the useFetcher (or useSubmit) Vs query params or changing the URL.
To give an example and make it easier to explain perhaps, we have a table with our data, that has some buttons that act as data filters. So I'm using the route loader to request the table data. No worries there.
When the user clicks one of the filter buttons, it requests the matching data from the backend. So at first, I thought as this wouldn't be a change in navigation, I would need to use a fetcher. Probably fetcher.load()?
But then the table wasn't rerendering with the new data because I misunderstood that the result of the use fetcher doesn't change the data from useLoaderData(). So it would be possible to conditionally use the fetcher data, and if undefined, use the loader data but this felt a bit fiddly and probably not correct.
So the next option I tried was to adjust the URL directly. So when the filter button gets clicked, it changes the URL directly and appends a query argument which the loader picks up, and because the URL changes, the loaders auto revalidate and the table gets the new data.
This works and feels more like the remix way? But still a bit confused when to use the fetcher precisely, or if this URL change isn't the best way and there could be another? ๐
Similarly, the table has a search input, which would need to query the backend again to filter the returned results (as the table is paginated). So would the best way to do this also be the URL query args and rely on remix's auto cancellation? Debounce? Or a fetcher (submit or load? ๐ )
Any pointers, suggestions, or extra reading much appreciated!