Context and loader data serialization
Hi all, I encountered an issue when trying to put a Set into loader data. It looks like TSR was trying to serialize and deserialize on page reload or something. Is there anything I can use to control how this works? I searched the docs and couldn’t find anything. And does it also apply to context, or other data stored in TSR?
12 Replies
metropolitan-bronze•3mo ago
is this for router or start?
router does not serialize context or loader data
extended-salmonOP•3mo ago
Ahh I see. Thought it was Router but maybe it's Start! I am using Start
Does Start serialize the data? for ssr I guess?
metropolitan-bronze•3mo ago
yes it does
extended-salmonOP•3mo ago
Is there a function I can pass to control serialization or should I just only store serializable data?
metropolitan-bronze•3mo ago
right now it's not customizable
so only json serializable (and date) is supported
but we are working on making the serializer support more / almost all JS types
also there will be a plugin mechanism to handle custom types/ classes
extended-salmonOP•3mo ago
Perfect, thanks! Will stick with serializable for now
conscious-sapphire•2mo ago
@Manuel Schiller Curious to know what the priority/progress around what you described above as this is directly related to the issue I am currently encountering. Thanks!
https://discord.com/channels/719702312431386674/1382373161944748032 for ref
metropolitan-bronze•2mo ago
the customizable serialization will be one of the next things i will be implementing
extended-salmon•2mo ago
This would allow setting React/JSX components in context?
I was trying to have a dynamic action (create button, etc) section in the page header based on the page and was running into issues.
Not a big deal, can work around it.
metropolitan-bronze•2mo ago
yes, if you don't serialize you can put anything in there
conscious-sapphire•2mo ago
Great to hear. is there anywhere I can monitor progress so I ensure I stay updated? discord isn't great for me 😓
metropolitan-bronze•2mo ago
this is just planned but no PR or anything else exists yet