zoukankan      html  css  js  c++  java
  • react源码分析

    ReactMount.render -> ReactMount._renderSubtreeIntoContainer

    -> ReactMount._renderNewRootComponent -> ReactMount.batchedMountComponentIntoNode

    -> ReactReconciler.mountComponent -> ReactDomComponent.mountComponent

    -> ReactDomComponent._createContentMarkup ->ReactMultiChild.mountChildren

    ->  ReactMount._mountImageIntoNode -> ReactMount.setInnerHTML

    ReactMount._mountImageIntoNode负责将virtualdom实际mount到dom上,

    先是用ReactMarkupChecksum.canReuseMarkup检查是不是可以复用的markup

    /**
     * Mounting is the process of initializing a React component by creating its
     * representative DOM elements and inserting them into a supplied `container`.
     * Any prior content inside `container` is destroyed in the process.
     *
     *   ReactMount.render(
     *     component,
     *     document.getElementById('container')
     *   );
     *
     *   <div id="container">                   <-- Supplied `container`.
     *     <div data-reactid=".3">              <-- Rendered reactRoot of React
     *       // ...                                 component.
     *     </div>
     *   </div>
     *
     * Inside of `container`, the first element rendered is the "reactRoot".
     */
        if (transaction.useCreateElement) {
          while (container.lastChild) {
            container.removeChild(container.lastChild);
          }
          container.appendChild(markup);
        } else {
          setInnerHTML(container, markup);
        }

    Transaction

    /*
     * Use cases:
     * - Preserving the input selection ranges before/after reconciliation.
     *   Restoring selection even in the event of an unexpected error.
     * - Deactivating events while rearranging the DOM, preventing blurs/focuses,
     *   while guaranteeing that afterwards, the event system is reactivated.
     * - Flushing a queue of collected DOM mutations to the main UI thread after a
     *   reconciliation takes place in a worker thread.
     * - Invoking any collected `componentDidUpdate` callbacks after rendering new
     *   content.
     * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
     *   to preserve the `scrollTop` (an automatic scroll aware DOM).
     * - (Future use case): Layout calculations before and after DOM updates.
     *
     * Transactional plugin API:
     * - A module that has an `initialize` method that returns any precomputation.
     * - and a `close` method that accepts the precomputation. `close` is invoked
     *   when the wrapped process is completed, or has failed.
     *
     * @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
     * that implement `initialize` and `close`.
     * @return {Transaction} Single transaction for reuse in thread.
     *
     * @class Transaction
     */
  • 相关阅读:
    regsvr32 错误解决方案
    cefsharp解决闪烁
    WPF使用cefsharp 下载地址
    Winform下CefSharp的引用、配置、实例与报错排除(源码)
    cefSharp在XP下使得程序崩溃记录
    mvc3在window 7 iis7下以及 xp iis 5.1下的部署 ,asp.net MVC3无法打开项目文件E:/我们的项目/Project/HeatingMIS.Web/HeatingMIS.Web.csproj”。此安装不支持该项目类型。
    顺序程序设计
    你对linux了解多少,Linux 系统结构详解!
    算术运算符和算术表达式(优先级,结合性等)
    离散化和面元划分(可以理解为划分段)
  • 原文地址:https://www.cnblogs.com/TLightSky/p/4835539.html
Copyright © 2011-2022 走看看