Perform state updates in synchronous order

Viewed 22

Hi I want to update a certain state right after setting another. This has to happen in a synchronous order to prevent undesired effects.

useEffect(() => {
    if (customDate.from && customDate.to) {
        applyFilter(customDate);
        setCustomDate([]);
    }
}, [customDate, applyFilter]);

Right now it's working, but i've read that state updates are asynchronous. How can i make sure it happens in synchronous orders.

0 Answers
Related