zoukankan      html  css  js  c++  java
  • Virtual DOM--react

    Consider a DOM made of thousands of divs. Remember, we are modern web developers, our app is very SPA! We have lots of methods that handle events - clicks, submits, type-ins… A typical jQuery-like event handler looks like this:

    • find every node interested on an event
    • update it if necessary

    Which has two problems:

    1. It’s hard to manage. Imagine that you have to tweak an event handler. If you lost the context, you have to dive really deep into the code to even know what’s going on. Both time-consuming and bug-risky.
    2. It’s inefficient. Do we really need to do all this findings manually? Maybe we can be smarter and tell in advance which nodes are to-be-updated?

    https://www.cnblogs.com/feng9exe/p/10906496.html

    Virtual DOM

    1. React uses the Virtual DOM to create an in-memory copy of the browsers DOM
    2. When changing the state of components, React updates the virtual DOM first
    3. After that it computes the resulting differences, and updates the browser’s displayed DOM efficiently

    virtual DOM ReactJS

    https://blog.codecentric.de/en/2017/11/developing-modern-offline-apps-reactjs-redux-electron-part-2-reactjs-basics/

    1. The Virtual DOM: As discussed above, React.js brought in the helpful Virtual DOM - a virtual browser infinite times friendlier than the real browser. You may take it as the middleman sitting between the developer and the real browser.

      The Virtual DOM

      The Virtual DOM assists React by modeling two versions of the DOM: the original and the updated one which reflects the changes made on the view. The framework then notes the differences and updates only the parts of the UI that differ from the original. Hence, easing the previous SSR version where they had to recreate the entire updated view.

    https://dzone.com/articles/react-is-taking-over-front-end-development-why

  • 相关阅读:
    java去掉List中的重复值代码
    jquery 请求jsp传递json数据的方法
    jsp自定义标签分析
    jquery mouseout事件冒泡解决方法
    java split函数 对空的处理
    log4j使用感受
    mysql数据库主外键级联删除脚本RESTRICT --> CASCADE
    jquery 实现层级下拉框联动效果 代码
    JSP图片上传 公共工具类
    Apache和Nginx的对比
  • 原文地址:https://www.cnblogs.com/feng9exe/p/11084558.html
Copyright © 2011-2022 走看看