I have a problem refreshing the function to rerun the API to get the latest data to show in the table using ReactJs. Below is my react coding. Now my coding is creating the setTimeout function into use effect there to rerun every 10 seconds and follow this StackOverflow question I want to refresh the api section every 10 secondes with React, but it doesn't work.
const getTodayList = useCallback(() => {
getTodayQueueList().then((response) => {
const queue = response.data.data;
setLists(queue);
toggleColumn();
});
}, []);
useEffect(() => {
getTodayList();
setTimeout(() => setRepeater(prevState=>prevState+1), 100000);
}, [getTodayList, repeater]);
This getTodayQueueList is get the API. The setLists(queue) to get the table data from API.
Because I want every 10 seconds to rerun API again to get the latest data into the table.
Hope someone can help me with how to solve this problem. Thanks.
