Why do have to use a function in ref when using gsap and react?
import React, { useRef, useEffect } from 'react';
import logo from './logo.svg';
import './App.css';
import gsap from 'gsap';
import gsapCore from 'gsap/gsap-core';
function App() {
let circleYellow = useRef(null)
let circleRed = useRef(null)
let circleBlue = useRef(null)
useEffect(()=> {
gsap.from(circleYellow, {duration: 0.8, opacity: 0, x: 90, ease: 'power3.out'})
gsap.from(circleRed, {duration: 0.8, opacity: 0, x: 90, ease: 'power3.out'})
gsap.from(circleBlue, {duration: 0.8, opacity: 0, x: 90, ease: 'power3.out'})
}, [])
return (
<div className="App">
<header className="App-header">
<div className="circle-container">
<div ref={el => circleYellow = el} className="circle circle--yellow"></div> <--- when I use just circleYellow I get this error: TypeError: Cannot add property _gsap, object is not extensible
<div ref={el => circleRed = el} className="circle circle--red"></div>
<div ref={el => circleBlue = el} className="circle circle--blue"></div>
</div>
</header>
</div>
);
}