3 ms·
THAT'S THE BEAUTY OF IT! Thing about async/await. const a = await doThing(); const b = await doOtherThing(); The order of the written code and the order
by paulddraper 3y ago
THAT'S THE BEAUTY OF IT!
Thing about async/await.
const a = await doThing();
const b = await doOtherThing();
The order of the written code and the order of the executed codes are two different things. Being able to write code in proximate/logical order is a enormous relief, even if things don't actually happen like that.
Same with hooks.
- danielvaughn 3y agoTo be fair I wasn't very clear, but what I meant was like this: function SomeComponent({ someProp }) { function doStuff() { // do stuff } useEffect(doStuff, [someProp]) } This trivial example is easy to read, but as more state and effects get added to a component, it quickly becomes fairly cumbersome to figure out the exact order in which your code runs.
- c-hendricks 3y agoThey're side effects, by the very nature of them, if you're putting them in your code you shouldn't care which order they run.