📌  相关文章
📜  第一次加载页面时如何不执行useEffect - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:19.937000             🧑  作者: Mango

代码示例2
const { useState, useRef, useLayoutEffect } = React;

function ComponentDidUpdateFunction() {
  const [count, setCount] = useState(0);

  const firstUpdate = useRef(true);
  useLayoutEffect(() => {
    if (firstUpdate.current) {
      firstUpdate.current = false;
      return;
    }

    console.log("componentDidUpdateFunction");
  });

  return (
    

componentDidUpdateFunction: {count} times

); } ReactDOM.render( , document.getElementById("app") );