admin管理员组文章数量:1320888
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 ??
Share Improve this question edited Jan 29 at 12:25 Peter_19 asked Jan 29 at 10:28 Peter_19Peter_19 113 bronze badges 4 |1 Answer
Reset to default 0React does not re-render immediately. Instead, it waits until the function completes and then processes state updates in batches.
本文标签: reactjsWhen is Rerendering in React triggeredStack Overflow
版权声明:本文标题:reactjs - When is Rerendering in React triggered? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742002661a2411330.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
@State
isn't part of vanilla react, you must be using something else to enable that decorator – Nick Parsons Commented Jan 29 at 11:26setState
in your function and then, when your function ends, pending changes can trigger rendering. – Wiktor Zychla Commented Jan 29 at 12:31