rzh9b
rzh9bā€¢6mo ago

onClick not staying with preact-render-to-string?

Hello, I'm trying to make an SSR application by rendering components to strings. However, I need a button to have some JavaScript capabilities and unfortunately Preact seems to be removing it. How can I work around this? I'd like to continue rendering it to a string if possible. Thanks!
6 Replies
fro.profesional
fro.profesionalā€¢6mo ago
You cannot serialize functions with render to string
rzh9b
rzh9bOPā€¢6mo ago
What's the alternative?
fro.profesional
fro.profesionalā€¢6mo ago
Hydrate the comoponents that u want on client Or use fresh which already does that But Iā€™m not sure how to do it sorry šŸ˜ž
rzh9b
rzh9bOPā€¢6mo ago
Ahhhh, hydration - I forgot about that. Thanks for your help!
fro.profesional
fro.profesionalā€¢6mo ago
GitHub
GitHub - preactjs/preact-iso: Isomorphic utilities for Preact
Isomorphic utilities for Preact. Contribute to preactjs/preact-iso development by creating an account on GitHub.
fro.profesional
fro.profesionalā€¢6mo ago
Maybe that can help