// 示例一 // import React, { useState } from "react"; // // 该组件的渲染是非常耗时的 // function ExpensiveCom() { // const now = performance.now(); // while (performance.now() - now < 200) {} // return
耗时的组件
; // } // function Input() { // // 维护了一组数据 // const [num, updateNum] = useState(0); // return ( // <> // updateNum(e.target.value)} /> //num is {num}
// > // ); // } // function App() { // return ( // <> // //耗时的组件
; } function Counter({ children }) { const [num, updateNum] = useState(0); return (num is {num}
{children}