Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batchUpdate #72

Open
HCLacids opened this issue Mar 17, 2024 · 0 comments
Open

batchUpdate #72

HCLacids opened this issue Mar 17, 2024 · 0 comments
Labels

Comments

@HCLacids
Copy link
Owner

react18以前
react有Transaction机制,可以给react的事件的开头和结尾附上isBathingUpdate变量的赋值,开头为true,结束为false。
简单来说,在 Transaction 的 initialize 阶段,一个 update queue 被创建。在 Transaction 中调用 setState 方法时,状态并不会立即应用,而是被推入到 update queue 中。函数执行结束进入 Transaction 的 close 阶段,update queue 会被 flush,这时新的状态会被应用到组件上并开始后续 Virtual DOM 更新等工作。
react18之后
https://zhuanlan.zhihu.com/p/382216973

@HCLacids HCLacids added the React label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant