Bootstrap

前端框架 react 性能优化 原创

function App() {
    console.log("App发生渲染")

    const [count, setCount] = useState(1)

    return (
        <>
            <div className="App">
                <Son/>
                <p>{count}</p>
                <button onClick={() => setCount(count => ++count)}>点击加1</button>
            </div>
        </>
    );
}

const Son = () => {
    console.log("Son发生渲染")
    return <div>
        <p>son</p>
        <GrandSon/>
    </div>
}

const GrandSon = () => {
    console.log("GrandSon发生渲染")

    return <div><p>GrandSon</p></div>
}
;