I know useEffect is the 'combination' of componentDidUpdate and componentDidMount? but since I have already passed in a dependency, why is it still load during the first load?
import React, { useState, useEffect } from "react"; import { Button, Table, Column } from "antd"; const initData = [ { id: 1, name: "James" }, { id: 2, name: "John" } ]; function MyTable({ changeDataFlag }) { const [data, setData] = useState(initData); useEffect(() => { setData( data.map(o => ({ id: "Titus", name: "Paul" })) ); }, [changeDataFlag]); return ( <Table dataSource={data} rowKey={data => data.id}> <Column title="Id" dataIndex="id" /> <Column title="Name" dataIndex="name" /> </Table> ); } export default MyTable; I expect to see James and John on the table before I click update button