The ESPs and other advanced boards (not the UNO) need to run multiple functions "In the background" like keeping WiFi connected, managing the TCP/IP stack etc.
the code architecture is such that when you call delay() or when the loop() loops, those tasks are given a bit of time to complete their work but if your code is blocking for too long — like an active wait on a button press or some network event or whatever — these functions will be prevented from running and the watchdog will kick-in believing that the arduino has crashed and this can cause your ESP to reset itself.
So one way to avoid such unwanted reboot is to not have blocking code but if you need to then calling yield()
(or delay(0)
will give a chance to those functions to run.
on small arduinos like a UNO, the function is defined as weak, meaning it can be overridden, and is an alias for a function doing nothing
so it does not hurt on a UNO to call yield() when you have blocking code and if you take this code to an ESP you'll be in a good place