当前位置: 首页 > 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.dinnco.com/news/45631.html

相关文章:

  • 网站建设开发服务费怎么做分录软文推广
  • dede网站怎么备份一键搭建网站工具
  • 谁有国外hs网站除了百度指数还有哪些指数
  • 网站加外链网站页面排名优化
  • 简单网站建设公司产品seo优化
  • 青岛网站公司网站制作平台
  • 电商网站开发平台哪家好百度站长工具怎么用
  • 网站做强制访问控制运营推广是做什么的
  • 美女做游戏广告视频网站网络营销策划与推广
  • 专升本要什么条件网站页面优化方法
  • 电子商务网站建设实验指导惠州seo按天付费
  • 深圳网站品牌推广深圳建站公司
  • 网站怎么做优化推广网络推广的网站有哪些
  • 北京企业网站报价seo问答
  • wordpress浮动小人玉林网站seo
  • 找做网站公司需要注意什么条件hao123主页
  • wordpress 主菜单插件seo推广排名软件
  • 公司做卖网站有前景吗外贸谷歌推广怎么样
  • 学设计的网站有哪些app推广工作靠谱吗
  • 湖北平台网站建设制作微信引流用什么软件好用
  • 免费网站创建少女长尾关键词挖掘
  • 2022昆明今天刚刚发生的新闻网站seo诊断分析和优化方案
  • 在线设计网站大全宁波seo优化排名
  • 专业的网站设计公司百度推广怎么做效果好
  • 在线做任务的网站有哪些互联网营销师培训机构
  • 音乐网站开发参考文献湖南seo排名
  • 做视频网站服务器怎么选择网络营销推广策划的步骤
  • 宁波网站建设哪家强广西网站建设制作
  • 丛台企业做网站推广年度关键词
  • 建设企业门户网站怎样建立自己网站