Non serializable objects in Route Context #4693
Unanswered
check24-danielpaschsannapiu
asked this question in
Q&A
Replies: 0 comments
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.
-
I have an API client that is required on the client and on the server. All examples I see for tanstack just initializes these things in a global way, but that doesn't work when you need to pass arguments.
I have a few config variables that I fetch from the server and with that I can initialize the client.
I do this in the root route beforeLoad
Now any route can use that client like so:
Now I wanna use that in component.
Problem is this won't work, because $contentApi is no longer the real client, it has been serialized/deserialized I think.
My hack around this currently is re-creating the api client in a context and using the context in the component instead.
But loaders now use the route context and components need to use the context, that's odd to me. Is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions