📜  react useEffect prevent first time - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:35.257000             🧑  作者: Mango

代码示例2
import { useRef, useEffect } from 'react';

export function useFirstRender() {
  const firstRender = useRef(true);

  useEffect(() => {
    firstRender.current = false;
  }, []);

  return firstRender.current;
}