使用State Hook
02. 使用State Hook123456789101112131415import React, { useState } from 'react';function Example() { // 声明一个叫 "count" 的 state 变量 const [count, setCount] = useState(0); return ( <div> <p>You clicked {count} times</p> <button onClick={() => setCount(count + 1)}> Click me </button> </div> );} 我们将通过将这段代码与一个等价的 class 示例进行比较来开始学习 Hook。 等价的Class组件示例1234567891011121314151...






