DEV Community

Discussion on: How to rehydrate typed data?

Collapse
 
nombrekeff profile image
Keff

Interesting solution!

The only thing that bothers me a bit is the fact that the dehydrated result contains a lot of extra data, and requires this extra data to hydrate it, forcing you to use hydration-next for both hydrating and dehydrating. I see an issue with this, what if the data comes from an api that does not return that extra data. How would it be handled in that case?

Collapse
 
kamil7x profile image
Kamil Trusiak

If there is no _types field, the original object is returned, so it will work same as JSON.parse.