📌  相关文章
📜  如何在反应钩子上使用`setState`回调 - Javascript代码示例

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

代码示例1
//You need to use useEffect hook to achieve this.

const [counter, setCounter] = useState(0);

const doSomething = () => {
  setCounter(123);
}

useEffect(() => {
   console.log('Do something after counter has changed', counter);
}, [counter]);