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

  • 相关阅读:
    【技术博客】利用handler实现线程之间的消息传递
    BUAA软件工程个人作业-软件案例分析
    BUAA软件工程结对项目作业
    BUAA软件工程个人项目作业
    BUAA软件工程个人博客作业
    BUAA-软件工程第一次作业
    BUAA-OO-最后单元总结
    BUAA-OO-第三单元总结
    BUAA-OO-第二单元总结
    第四单元总结&&OO总结
  • 原文地址:https://www.cnblogs.com/feng9exe/p/11084558.html
Copyright © 2011-2022 走看看