Question (for those familiar w/ React and GSAP) regarding setting Timeline with functional components.
I'm aware that to access DOM, I would have to reference and set animation like so, which works just fine:
// creating state objects
const [animation, setAnimation] = useState();
// Set variable using useRef for functional component
let headingRef = useRef(null);
// add reference to the DOM element
<h1 ref={element => {headingRef = element;}}>Hello</h1>
/ // animate using useEffect hook and setAnimation
useEffect(() => {
setAnimation(
TweenMax.to(headingRef, 1, {
css: {
height: 120,
},
})
);
}, []);
Now, what if I wanted to create a timeline. Do I just set it like so:
let tl = new TimelineMax();
Or do I need to store it in a state object?