Skip to content

How to pass in additional params to a data loader in Remix? #944

Answered by blittle
sid2364 asked this question in Help
Discussion options

You must be logged in to vote

Hi @sid2364, loaders execute before your component renders, so you cannot pass data from the component directly to the loader. This is because the components get rendered on the server (SSR), so all data needs to be fetched up front in the loaders before the page can SSR. Loaders should load data based on the request, which includes the URL and parameters within it (and cookies).

I'm not entirely sure what you are trying to accomplish with this count variable. If it doesn't make sense for it to be in the URL (?count=1 or something like that), you could create a resource route, which is essentially a route that has a loader and no UI. And then you can use useFetcher() to call the resource …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sid2364
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants