- Advanced TypeScript Programming Projects
- Peter O'Hanlon
- 267字
- 2021-06-24 13:27:12
How React uses a virtual DOM to be more responsive
I glossed over why the render method is used, so now is the time to address React's secret weapon, that is, the virtual Document Object Model (DOM). If you've been developing web applications for a while, you are probably aware of the DOM. If you have never encountered this, the DOM is an entity that describes exactly what a web page will look like. Web browsers rely very heavily on the DOM, and, as it has grown organically over the years, it can be pretty unwieldy. There is only so much that browser manufacturers can do to try and speed up the DOM. If they want to be able to serve up old web pages, then they have to support the full DOM.
The virtual DOM is a light weight copy of the standard DOM. The reason it is lighter in weight is that it misses out a major feature of the standard DOM; that is, it doesn't have to render out to the screen. When React runs the render method, it traverses each .tsx (or .jsx in JavaScript) file and executes the rendering code there. It then compares this rendered code to a copy of the last render that was run to work out exactly what has changed. Only those changed elements are updated on the screen. This comparison stage is the reason we have to use a virtual DOM. It's much faster to tell what elements need updating using this approach, and only those elements that get changed need to be updated.
- 嵌入式Linux開發技術
- Implementing Cisco UCS Solutions
- Instant Handlebars.js
- Kubernetes網絡權威指南:基礎、原理與實踐
- 嵌入式應用程序設計綜合教程(微課版)
- Linux集群和自動化運維
- 竹林蹊徑:深入淺出windows驅動開發
- Windows 7案例教程
- Learning Magento 2 Administration
- 寫給架構師的Linux實踐:設計并實現基于Linux的IT解決方案
- Windows 8實戰從入門到精通(超值版)
- Building Telephony Systems With Asterisk
- Windows 7使用詳解(修訂版)
- Learning BeagleBone
- Drupal 7 Cookbook