I'm using React Hooks, to asynchronous fetching data from database and showing them with Ant Design Table. In my code, the dataSource array (a state variable) does update, but Ant Design table does not. I realy need some help, Thanks.
I tried these answers, and unfortunately I could not solve my problem.
The useState set method is not reflecting a change immediately
React Hook useState Not Updating UI
my code is as follows:
const RequestList = ({ user }) => {
const [dataSource, setDataSource] = useState([]);
useEffect(() => {
async function startFetching() {
const { data: _dataSource } = await getRequests();
setDataSource((dataSource) => [...dataSource, ..._dataSource]);
}
startFetching();
}, []);
// ...
return <Table dataSource={dataSource} columns={columns} />;
};
export default RequestList;