-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
精读《Javascript 事件循环与异步》 #41
Comments
第一段代码等价于
React 不会对componentWillMount进行await调用,new Promise(resolver)里的resolver是同步执行的,所以实际上这段代码就等价于this.setState({a:1}),componentWillMount中同步调用setState不会触发rerender。
这里的setState是在内部Promise的then回调里执行的,所以是异步执行的,所以会触发rerender。 |
老铁 666 |
本周阅读的文章:传送门
事件循环作为 js 的基础特性,掌握后可以提高每一行代码的质量。
The text was updated successfully, but these errors were encountered: