jordanreger
jordanregerā€¢7mo 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ā€¢7mo ago
You cannot serialize functions with render to string
jordanreger
jordanregerOPā€¢7mo ago
What's the alternative?
fro.profesional
fro.profesionalā€¢7mo 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 šŸ˜ž
jordanreger
jordanregerOPā€¢7mo ago
Ahhhh, hydration - I forgot about that. Thanks for your help!
fro.profesional
fro.profesionalā€¢7mo 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ā€¢7mo ago
Maybe that can help

Did you find this page helpful?