Skip to content
Discussion options

You must be logged in to vote

Ideally, you move the useFetcher to a parent component of all your components needing the data, and then share it through props or context.

There's also an useFetchers() hook (note the plural) which returns the list of fetchers, similar to useMatches, but there's no simple way to identify a specific fetcher, you will have to do a fetcher.find and check if one of them has the data you need.


Side question, why are you using a POST to do a search? It would be simpler to do fetcher.load(/route?term=${encodeURIComponent(term}) and do a GET request, with the benefit that Remix will not re-load all routes loaders after every request (when there's a POST against an action, Remix will revalidate …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@kwiat1990
Comment options

@kiliman
Comment options

Answer selected by kwiat1990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants