Thank you so much for such a fast and friendly response! I did not realize that context is such an important thing when using GSAP with React! I havent seen the post about it earlier. I'll dive deep into that now.
Here is the updated code that works just like i wanted to (for anyone that encounters the same issue!)
import {gsap} from "gsap";
import {ScrollTrigger} from "gsap/all";
import {useEffect, useRef} from "react";
//import {Link} from "react-router-dom";
//import {cursorEnterAnimation, cursorLeaveAnimation} from "../../utils/animations";
import {SplitText} from "gsap/all";
gsap.registerPlugin(ScrollTrigger);
gsap.registerPlugin(SplitText);
const Work = () => {
let component = useRef(null);
useEffect(() => {
let ctx = gsap.context(() => {
gsap.to("#text-container", {
scrollTrigger: {
trigger: "#project-container",
start: "top 40%",
end: "bottom 40%",
pin: "#text-container",
pinSpacing: false,
markers: true,
},
});
}, component);
return () => ctx.revert();
}, []);
return (
<div ref={component} className="flex w-full flex-col items-center justify-between text-white">
<div id="project-container" className="relative flex h-[170vh] items-center justify-center">
<div className="mr-[20vw] h-[60vh] w-[600px] bg-red-400"></div>
<div
id="text-container"
className="absolute top-0 flex flex-col items-center justify-center text-primary"
>
<h1 className="text-center text-8xl font-bold">TITLE</h1>
<h2 className="mt-5 text-center font-grandslang text-xl font-medium">
Project & Development
</h2>
<button className="mt-12 text-center font-medium tracking-widest underline">
VIEW PROJECT
</button>
</div>
</div>
<div className="flex h-[170vh] items-center justify-center">
<div className="mr-[20vw] h-[60vh] w-[600px] bg-red-400"></div>
</div>
</div>
);
};
export default Work;