I have to update the state and use it in the function. It doesn't happen because I can't keep it waiting in the current system. It takes previous data and runs it. How can I hold it?
For example, the last value of the page is 1 when 3. Click is running and it should work as 1 in getReports, but 3 works. The next one is 1, but I need that instant.
const onClick = () => {
setReports([]);
setPage(1);
getReports(); <- use page and reports list
}