当前位置: 首页 > news >正文

天津网站页面设计杭州网站建设 乐云践新专家

天津网站页面设计,杭州网站建设 乐云践新专家,做网站费用分几块,学校网站建设招标公告HostText 1 )概述 在 completeWork 中 对 HostText的处理在第一次挂载和后续更新的不同条件下进行操作 第一次挂载主要是创建实例后续更新其实也是重新创建实例 2 )源码 定位到 packages/react-reconciler/src/ReactFiberCompleteWork.js#L663 到 c…

HostText


1 )概述

  • completeWork 中 对 HostText的处理
  • 在第一次挂载和后续更新的不同条件下进行操作
    • 第一次挂载主要是创建实例
    • 后续更新其实也是重新创建实例

2 )源码

定位到 packages/react-reconciler/src/ReactFiberCompleteWork.js#L663

case HostText 这里

case HostText: {let newText = newProps;// 符合这个条件,说明它不是第一次渲染,就是更新的状态// 调用 updateHostText 进行更新if (current && workInProgress.stateNode != null) {const oldText = current.memoizedProps;// If we have an alternate, that means this is an update and we need// to schedule a side-effect to do the updates.updateHostText(current, workInProgress, oldText, newText);} else {// 对于第一次渲染if (typeof newText !== 'string') {invariant(workInProgress.stateNode !== null,'We must have new props for new mounts. This error is likely ' +'caused by a bug in React. Please file an issue.',);// This can happen when we abort work.}// 跳过 context 处理const rootContainerInstance = getRootHostContainer();const currentHostContext = getHostContext();// 跳过 hydrate 处理let wasHydrated = popHydrationState(workInProgress);if (wasHydrated) {if (prepareToHydrateHostTextInstance(workInProgress)) {markUpdate(workInProgress);}} else {// 创建 文本 实例workInProgress.stateNode = createTextInstance(newText,rootContainerInstance,currentHostContext,workInProgress,);}}break;
}
  • 进入 updateHostText

    updateHostText = function(current: Fiber,workInProgress: Fiber,oldText: string,newText: string,
    ) {// 这个非常简单,通过前后 text 是否有区别// 如果不同,则创建新的 text实例if (oldText !== newText) {// If the text content differs, we'll create a new text instance for it.// 先跳过 context 的处理const rootContainerInstance = getRootHostContainer();const currentHostContext = getHostContext();workInProgress.stateNode = createTextInstance(newText,rootContainerInstance,currentHostContext,workInProgress,);// We'll have to mark it as having an effect, even though we won't use the effect for anything.// This lets the parents know that at least one of their children has changed.markUpdate(workInProgress);}
    };
    
    • 进入 createTextInstance
      // packages/react-dom/src/client/ReactDOMHostConfig.js#L272
      export function createTextInstance(text: string,rootContainerInstance: Container,hostContext: HostContext,internalInstanceHandle: Object,
      ): TextInstance {if (__DEV__) {const hostContextDev = ((hostContext: any): HostContextDev);validateDOMNesting(null, text, hostContextDev.ancestorInfo);}const textNode: TextInstance = createTextNode(text, rootContainerInstance);// 这个方法之前阅过precacheFiberNode(internalInstanceHandle, textNode);return textNode;
      }
      
      • 进入 createTextNode
        export function createTextNode(text: string,rootContainerElement: Element | Document,
        ): Text {// 最终 getOwnerDocumentFromRootContainer 这里返回一个dom对象,调用dom的 createTextNode 这个方法return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text,);
        }
        
        • 进入 getOwnerDocumentFromRootContainer
        function getOwnerDocumentFromRootContainer(rootContainerElement: Element | Document,
        ): Document {// rootContainerElement.ownerDocument 这里是 window.document 对象// 这么做是为了兼容多平台api的使用return rootContainerElement.nodeType === DOCUMENT_NODE? (rootContainerElement: any): rootContainerElement.ownerDocument;
        }
        
  • HostText 相比于 HostComponents 来说,它没有多种选择

  • 没有各种各样的属性,整体来说非常的简单

  • 一些特别说明的,写在了上述代码注释中

http://www.yayakq.cn/news/26916/

相关文章:

  • 移动网站打不开苏州专业网站建设
  • 制作网站一般多少钱慧达seo免登录发布
  • 搭建网站开发网站环境厦门唯一官方网站
  • 中山微网站建设报价上海高端建设网站
  • ai智能建站保定网站建设咨询
  • 芜湖网站 建设响应式外贸网站案例
  • 中山建设网站南充做网站电话
  • 广告传媒公司网站怎么做南昌做网站开发的公司
  • 外链建设对网站的影响线上广告代理平台
  • 外贸网站建设公司服务百度如何建网站
  • 网站建设招标方案wordpress 安装 此网页包含重定向循环
  • 文化馆网站建设方案做网站策划遇到的问题
  • 广州开发网站建设医疗门户网站管理系统
  • 南通手机建站模板怎么样做推广最有效
  • 响应式网站注意事项做数据ppt模板下载网站
  • 无锡手机网站建设公司企业域名邮箱
  • 萧山中兴建设有限公司网站手机优化软件
  • 辽宁省营商环境建设局网站网站logo在哪里修改
  • 网站应急响应机制建设情况js开发安卓app
  • 云南百度小程序开发数字营销网站主页优化
  • 如何用cms做网站天迈装饰网站建设项目
  • 什么是网站设计种类昆明做网站的旅行社
  • 卧龙区2015网站建设口碑自应式网站
  • 海尔网站建设情况佛山营销网站建设推广
  • 兰州市城关区建设局网站九江市建设工程质量监督站网站
  • 廊坊网站建设策划如何查看网站建设的时间
  • 做电影网站挣钱wordpress 缩略图加上alt
  • 电商商城网站网站建设的公司选哪家
  • 免费网站托管平台网站制作需要学什么
  • 莆田外贸网站建设给艺术家做网站的工作