Imagine you have this scenario
useEffect(() => {
console.log('query changed');
setSomething(1)
getStuff();
}, [props.match.params.query])
const getStuff = async () => {
console.log(something)
}
I've found in this scenario that something will always be the previous value. So for example if you change the props and something is 2, it will call setSomething(1), and put it into the queue. However, by the time you're inside getStuff, something will still be 2. How do you make it so that the setState function always applies before the next function is called?