Using hooks inside of loaders
Is it expected to not be able to use hooks inside of loaders?
8 Replies
stormy-goldā¢3y ago
You cannot call them
š
deep-jadeOPā¢3y ago
Man this is causing so many issues š¦
Any idea how to get around it? At this point I just want to be able to set initial data in the loader via the global store
actually nm I got it
lovely library
btw
thank you
I do have another question @Tanner Linsley if you dont mind:
Why
ensureQueryData and the useQuery?stormy-goldā¢3y ago
If the data is already there it will resolve immediately and query in the background.
deep-jadeOPā¢3y ago
Thanks
rare-sapphireā¢3y ago
sorry to hijack but I had the same question, if I can't use hooks how am I supposed to use the useLoader hook in the loader function of the route?
vicious-goldā¢3y ago
The trick is you shouldn't š Here is my example of route loader with tanstack-loaders:
And then inside of a route you're using it like this
stormy-goldā¢3y ago
It's a form of currying
You have all the variables you need to run the hook in
loader, so it makes sense to formulate it there, then ship it down the line to be called later.automatic-azureā¢2y ago
Hello, what solution did you use please ?