useState
useState is a hook function that comes with react, and its function is to declare state variables.
Declaration method:
const [ count , setCount ] = useState(0);
use
<div>{
count}</div>
Change value
setCount(i) // 调用setCount方法参数是想要修改的值
Note:
React Hooks cannot appear in the conditional judgment statement, because it must have exactly the same rendering order.