刚刚看到http://davidchang.github.io/ngReact/
将Reactjs和Angularjs整合起来。使用Reactjs来实现Angularjs的指令部分,只负责渲染。
怎么看待这种组合?
有什么益处?弊端?
过去多啦不再A梦2017-05-15 16:52:29
I hope someone who knows something about this can give me some advice, thank you very much.
我想大声告诉你2017-05-15 16:52:29
I don’t know much about react, but I can try to explain:
Due to angular's automatic dirty checking mechanism, angular's rendering is very time-consuming. Its dirty checking records all ngBind elements in the dom element, and then determines the changes and replaces the content in each $digest loop. One problem with this is that if there is too much data in the page, the more DOM elements will be manipulated and the efficiency will be lower. Therefore, Angular has a ngRepeat upper limit of 2000.
Since React has no templates, it uses js for rendering and operations in memory instead of directly manipulating the DOM. This is very fast, so the combination of the two will have an order of magnitude improvement in UI rendering, which is suitable for large quantities. Data presentation will be of great help.
As for the shortcomings, does it count that I don’t like react? Angular's template is a big advantage, what you see is what you get, everything is instructions, it is still html; on the contrary, the way react writes html as component, I think the optimization and maintenance cost is too high, es7 will have Object.observe Function, by then the efficiency of ng will be greatly improved.
What I don’t understand: How to handle DOM events after combining the two? How to proceed with two-way data binding? If two-way data binding is not required, Angular has built-in one-time binding syntax since 1.3: {{ ::expression }}, which will greatly alleviate the problem of low efficiency of two-way data binding. Corrections are welcome.