TanStackT
TanStack9mo ago
26 replies
spotty-amber

how come Route context becomes serialized objects on hydration

I notice in my component that class instances I've added to a route's context via beforeLoad are no longer the instances on initial render on the client. It seems odd. I expect that from the output of loader but not for beforeLoad.

Is my assumption incorrect that the merged values into the context via beforeLoad would be the actual objects?

```
const { myInstance } = useRouteContext();

console.log(myInstance.hello()); // error "hello" is not a function

...

beforeLoad: () => {
return {
myInstance: new Hello(),
};
}
Was this page helpful?