Hello I have question about how to use gsap in React and Specially in Gatsby
I have installed gsap new version with npm install ./gsap-bonus.tgz
In my gatsby-browser.js I define all plugins Globaly so use all those features without import them in another files
only gsap.to() works
here is my gatsby-browser.js:
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/
// You can delete this file if you're not using it
impor
Read gatsby's docs.
https://www.gatsbyjs.org/docs/debugging-html-builds/
You need to check if window is defined, or move it into componentDidMount or useEffect hook.
import { gsap } from "gsap"
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { CSSRulePlugin } from "gsap/CSSRulePlugin";
if (typeof window !== "undefined") {
gsap.registerPlugin(ScrollTrigger, CSSRulePlugin);
}