Thanks! Codesandbox is giving me server errors so I have a local Nextjs setup attempting to create an implementation of the Vue example here:
https://codepen.io/cassie-codes/pen/LYQaOBm
Running into an error when calling Flip.getState in the effect cleanup: TypeError: Cannot read properties of null (reading '_gsap')
import { Flip } from "gsap/dist/Flip";
import { gsap } from "gsap";
import { useEffect, useRef } from "react";
function Potions() {
gsap.registerPlugin(Flip);
let iconRefs = useRef([]);
useEffect(() => {
let iconRefValue = null;
if (iconRefs.current) {
iconRefValue = iconRefs.current;
Flip.getState(iconRefValue); // Works
}
return () => {
if (iconRefValue) {
Flip.getState(iconRefValue); // Doesn't work
}
};
}, []);
return (
<>
<img
className="avatar flipMe"
ref={(el) => {
iconRefs.current.push(el);
}}
src="/person.svg"
/>
<img
className="potion flipMe"
ref={(el) => {
iconRefs.current.push(el);
}}
src="/potions.svg"
/>
<img
className="spell flipMe"
ref={(el) => {
iconRefs.current.push(el);
}}
src="/spell.svg"
/>
</>
);
}
export default Potions;