Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(useFlip): prevent registerPlugin from running on server #301

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

evertmonk
Copy link
Contributor

I got the following error in a project using this hook.

web:dev:  ⨯ TypeError: gsap__WEBPACK_IMPORTED_MODULE_2__.registerPlugin is not a function
web:dev:     at eval (webpack-internal:///../../node_modules/.pnpm/@mediamonks+react-kit@1.0.1_react@18.2.0/node_modules/@mediamonks/react-kit/dist/gsap/hooks/useFlip/useFlip.js:14:35)

After inspecting other hooks I saw that the other hooks have a safeguard to prevent it from running on the server.

if (typeof window !== 'undefined') {
  gsap.registerPlugin(plugin);
}

This safeguard was missing for this hook so this PR is adding that to the useFlip hook.

@evertmonk evertmonk added the bug Something isn't working label Jan 18, 2024
@leroykorterink leroykorterink merged commit 691b3a9 into main Jan 18, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants