使用规则
1. 只能在组件中或者其他自定义Hook函数中调用
2. 只能在组件的顶层调用,不能嵌套在 if、for、其他函数中
import { useState } from "react"
//1.组件外使用--错误
// useState{''}
function App () {
//2.if for 组件内部函数--错误
// if(Math.random()>0.5){
// useState()
// }
return (
<div>
this is App
</div>
)
}
export default App