When does ReRendering exactly happen in React. At the end of the method or right away ?
// This is pseudo React Code
class myComponent {
@State
String x;
someFunction() {
  x= x+" World"; // line 1
  .
  .
  // a lot of code in this function 
  // line 149
}
}
So when will rerender happen. On Line 1 or after Line 149 ??
When does ReRendering exactly happen in React. At the end of the method or right away ?
// This is pseudo React Code
class myComponent {
@State
String x;
someFunction() {
  x= x+" World"; // line 1
  .
  .
  // a lot of code in this function 
  // line 149
}
}
So when will rerender happen. On Line 1 or after Line 149 ??
React does not re-render immediately. Instead, it waits until the function completes and then processes state updates in batches.


@Stateisn't part of vanilla react, you must be using something else to enable that decorator – Nick Parsons Commented Jan 29 at 11:26setStatein your function and then, when your function ends, pending changes can trigger rendering. – Wiktor Zychla Commented Jan 29 at 12:31