I'm a web developer and consultant, web GDE, and author of open source libraries. I co-founded 500Tech, a company that specializes in frontend technologies. I love coding, and love speaking about code
I think React tries to optimize based on the prediciton that the previous outcome will repeat itself.
So if the last time the state changed, it will start with lazy computation. But if the last time the state didn't change - it will start from eager computation. But that's just my guess, I haven't seen that in the code and I honestly have no idea.
Hi,
glad you learned something :)
That's the eager computation.
I think React tries to optimize based on the prediciton that the previous outcome will repeat itself.
So if the last time the state changed, it will start with lazy computation. But if the last time the state didn't change - it will start from eager computation. But that's just my guess, I haven't seen that in the code and I honestly have no idea.
I tried to demonstrate it here (forked your stackblitz):
stackblitz.com/edit/react-sync-asy...
Right you are! Thanks and sorry, missed that one while reading first time.