import { useRef } from 'react';
import gsap from 'gsap';
import { useGSAP } from '@gsap/react';
gsap.registerPlugin(useGSAP);
const { useRef } = React;
console.log(React.version);
function App() {
const container = useRef();
const circle = useRef();
useGSAP(
(context, contextSafe) => {
gsap.to(".box", { rotation: "+=360", duration: 3 });
gsap.to(circle.current, { rotation: "-=360", duration: 3 });
const onCircleClick = contextSafe(() => {
gsap.to(goodRef.current, { rotation: 180 });
});
circle.current.addEventListener('click', onCircleClick)
return () => {
circle.current.removeEventListener('click', onCircleClick);
};
},
{ scope: container }
);
return (
<div className="App">
<div ref={container} className="container">
<div className="box gradient-blue">selector</div>
<div className="circle gradient-green" ref={circle}>
Ref
</div>
</div>
<div className="box gradient-blue">selector</div>
</div>
);
}
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);