In a class component it's pretty easy to provide the desired order. If the state changes we always know when it really changed:
setState(updater[, callback])
From the documentation: "setState callback (setState(updater, callback)), either of which are guaranteed to fire after the update has been applied."
I need to execute a function with 100% guarantee after some state variable change and I need it to be done at the caller (because sometimes I don't need to call the function, so I can't useEffect here). Something like that:
setVar(10);
callFuncHere(); // <======= No guarantee var == 10 at the moment