0
点赞
收藏
分享

微信扫一扫

Log:2021-12-01

洛茄 2022-07-27 阅读 151


1.继续学习useState hook.

function Counter({initialCount}) {
const [count, setCount] = useState(initialCount);
return (
<>
Count: {count}
<button onClick={() => setCount(initialCount)}>Reset</button>
<button onClick={() => setCount(prevCount => prevCount - 1)}>-</button>
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button>
</>
);
}

  1. 学习useEffect hook


举报

相关推荐

0 条评论