T
TanStack2y ago
exotic-emerald

Using custom hooks in loader function

hi, i dont think the docs for Tanstack Router make it clear enough how to use hooks in your loader function. I understand it can be passed through context, but how will it be used? Passing the hook to the context and using it still throws the react error "hooks can only be used in components"
loader: ({ context: { useCustomHook} }) => {
console.log(useCustomHook()); // = error
},
loader: ({ context: { useCustomHook} }) => {
console.log(useCustomHook()); // = error
},
1 Reply
exotic-emerald
exotic-emerald2y ago
Is this a query or router question?

Did you find this page helpful?