📜  usestate array push - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:47.432000             🧑  作者: 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") );