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

Update 2017-02-14-lesson3.md #31

Open
wants to merge 2 commits into
base: remote-version
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _posts/2017-02-14-lesson3.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ likeButton.onStateChange = (oldEl, newEl) => {

非一般的暴力,因为每次 `setState` 都重新构造、新增、删除 DOM 元素,会导致浏览器进行大量的重排,严重影响性能。不过没有关系,这种暴力行为可以被一种叫 Virtual-DOM 的策略规避掉,但这不是本文所讨论的范围。

这个版本的点赞功能很不错,我可以继续往上面加功能,而且还不需要手动操作DOM。但是有一个不好的地方,如果我要重新另外做一个新组件,譬如说评论组件,那么里面的这些 `setState` 方法要重新写一遍,其实这些东西都可以抽出来,变成一个通用的模式。[下一节](http://react.huziketang.com/blog/lesson4)我们把这个通用模式抽离到一个类当中。
这个版本的点赞功能很不错,我可以继续往上面加功能,而且还不需要手动操作DOM。但是有一个不好的地方,如果我要重新另外做一个新组件,譬如说评论组件,那么里面的这些 `setState` 方法要重新写一遍,其实这些东西都可以抽出来,变成一个通用的模式。[下一节](http://huziketang.com/books/react/lesson4)我们把这个通用模式抽离到一个类当中。

* * *

Expand Down