输入关键词,开始搜索

↑↓ 选择↵ 打开esc 关闭
沉浸

useState

在函数组件中管理状态的基础 Hook。

useState

useState 是最常用的 React Hook,用于在函数组件中添加状态。

基本用法

JSX
import { useState } from 'react'; function Counter() {  const [count, setCount] = useState(0);   return (    <button onClick={() => setCount(count + 1)}>      Count: {count}    </button>  );}
未知标题
00:00
00:00
播放列表