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

为什么 React 16 版本中 render 阶段放弃了使用递归 #85

Open
nmsn opened this issue Feb 3, 2023 · 1 comment
Open

为什么 React 16 版本中 render 阶段放弃了使用递归 #85

nmsn opened this issue Feb 3, 2023 · 1 comment
Labels

Comments

@nmsn
Copy link
Owner

nmsn commented Feb 3, 2023

如题

@nmsn nmsn added the React label Feb 3, 2023
@nmsn
Copy link
Owner Author

nmsn commented Feb 3, 2023

因为递归是不能被中止的,需要一直占用线程,而 JS 又是属于单线程, 所以 当我们需要执行操作时,是不能被中断的,一旦执行,则需要全部操作执行完成后,才可释放线程

在这种情况下,我们在第一次渲染的时候,程序需要将 生成 Dom 和 包含事件 全部准备齐全后,才会添加 元素到 页面,并展示到浏览器,而用户看到的是,一直在等待中,才可看到画面,会导致用户体验极差

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