Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 618 Bytes

373.md

File metadata and controls

27 lines (22 loc) · 618 Bytes

关于 React hooks 的 caputre value,以下输出多少

::: tip 更多描述

function App() {
 const [count, setCount] = useState(0);
 const incr = () => {
   setTimeout(() => {
     setCount(count + 1);
   }, 3000);
 };
 return <h1 onClick={incr}>{count}</h1>;
}

当连续点击 10 次时,会输出多少 :::

::: tip Issue 欢迎在 Issue 中交流与讨论: Issue 373 :::

::: tip Author 回答者: zckpp :::

应该是1吧,在state被update之前count一直还是0