tmg0 / hero-motion

🌊 A shared layout animation tool for vue like framer motion.
MIT License
41 stars 3 forks source link

fix: only run `useLayout` in the client #223

Closed onmax closed 1 week ago

onmax commented 1 week ago

useStyle uses MutationObserver which causes an error when using SSR.

The current workaround is using <ClientOnly /> component.

Not sure if this is a good solution as I am not familiar with the codebase, but feel free to close this PR if using <ClientOnly /> is what we want.

Thanks for this great library 🫰

tmg0 commented 1 week ago

Thank you for your support of hero-motion

There may be a bug here, as we hope that hero-motion can be used in both client and server

For resolve the warning of MutationObserver in server env, we have referenced this PR and added check in useStyle, because return an undefind value in useLayout makes it completely unusable in an SSR environment (although, in reality, this only affects issues with child element scaling)

I will attempt to resolve this issue in the next major version, make hero-motion available in SSR mode.

Thank you for this PR!