Repository navigation
Add rehydrate hook to pages to enable rich data models in page props #13696
sandcastle
started this conversation in
Ideas
Replies: 2 comments
|
fwiw, I have found this solution, which presumably uses babel to patch the hydration process to use |
0 replies
|
SvelteKit does exactly this - it uses this library: https://github.com/Rich-Harris/devalue |
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.
Feature request
Is your feature request related to a problem?
Currently, when using
getStaticPropsit's not possible to use common JS objects likeDateor other objects that correctly serialize to JSON using atoJsonmethod. This forces client-side models to be anemic.Describe the solution you'd like
As far as I understand it, the problem is with rehydration on the client. If an optional hook into the rehydration process on the client was added, then you could overcome this issue. For cases where it is not required, no extra work is needed. But for cases such as ours where we have a rich domain model and are using classes, we would get the full benefit of the domain model.
An example of how this could work would be to add something like
rehydratePropsthat allows you to control the rehydration process:Describe alternatives you've considered
The current alternatives are not great and just feel like hacks:
Additional context
toJsonserialization/CC @Timer / @timneutkens / @AshConnolly / @thebillkidy
All reactions