1.引入
import React, {
useState } from 'react'
- 使用
const [count, setcount] = useState(0)
- 全部代码实现count加1
import React, {
useState } from 'react'
export default function Example() {
const [count, setcount] = useState(0)
return (
<div>
<p>click me {
count }</p>
<button onClick={
() => {
setcount(count + 1)}}>+1</button>
</div>
)
}