📅  最后修改于: 2022-03-11 14:57:19.937000             🧑  作者: Mango
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")
);