📜  React Hooks 追加状态 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:22.985000             🧑  作者: Mango

代码示例3
const {useState, useCallback} = React;
function Example() {
    const [theArray, setTheArray] = useState([]);
    const addEntryClick = () => {
        setTheArray([...theArray, `Entry ${theArray.length}`]);
    };
    return [
        ,
        
{theArray.map(entry =>
{entry}
)}
]; } ReactDOM.render( , document.getElementById("root") );