Replies: 1 comment
-
|
The fix: call the server function directly in const userQueryOptions = (id: string) => queryOptions({
queryKey: ['user', id],
queryFn: () => fetchUser({ data: id }), // call server fn directly, no hook
})
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm trying to figure out how to use
queryOptionstogether withuseServerFn.I'm trying to follow the pattern of creating predefined queries and use them from react:
This works on the client, but crashes when used on the loader.
I have tried creating a helper using
createIsomorphicFnto handle both cases but it doesn't seem like it works well either.Is there a "proper" way of doing this without code duplication?
The only solution that works reliably seems to duplicate the code:
Beta Was this translation helpful? Give feedback.
All reactions