(精华2020年5月25日更新) react基础篇 react-hooks的useState用法

import React , {useState} from 'react'

const addCon = ()=>{
    console.log(useState(0));
    
    const [count,setCount] = useState(0)
    const handelAdd = () =>{
        let newCount = count;
        setCount(newCount+=1)
    }
    return (
        <div>
            <p>{count}</p>
            <button onClick={handelAdd}>添加</button>
        </div>
    )
}

export default addCon

猜你喜欢

转载自blog.csdn.net/weixin_41181778/article/details/106324222
今日推荐