nnkystk / UsedRegulariy

よく使うファイルあれこれ
0 stars 0 forks source link

React useRef #14

Open nnkystk opened 2 years ago

nnkystk commented 2 years ago
const Sample = () => {

  const ref: any | null = useRef(null);

  useEffect(() => {
    console.log(ref.current);
    console.log(
      JSON.stringify(ref.current.getBoundingClientRect())
    );
  }, []);

  return (
    <div ref={ref}>
      <h1> Sample </h1>
    </div>
  );
};