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

jsp动态网站开发案例教程下载人员优化方案怎么写

jsp动态网站开发案例教程下载,人员优化方案怎么写,浅谈企业网站建设的目标,团队协同网站开发HostComponent & HostText 1 )概述 HostComponent 就是我们dom原生的这些节点, 如: div, span, p 标签这种 使用的是小写字母开头的这些节点一般都认为它是一个 HostComponent HostText,它是单纯的文本节点主要关注它们的一个更新过程 2 &#xf…

HostComponent & HostText

1 )概述

  • HostComponent 就是我们dom原生的这些节点, 如: div, span, p 标签这种
    • 使用的是小写字母开头的这些节点一般都认为它是一个 HostComponent
  • HostText,它是单纯的文本节点
  • 主要关注它们的一个更新过程

2 )源码

定位到 packages/react-reconciler/src/ReactFiberBeginWork.js
进入 updateHostComponent 这个API

function updateHostComponent(current, workInProgress, renderExpirationTime) {// 这个先跳过pushHostContext(workInProgress);if (current === null) {// 对于整个应用来讲,如果需要复用服务端渲染返回的dom内容,只有 HostComponent 和 HostText// 是需要被复用的,对于 class component 和 function component 本身是不对应于dom的某个节点的// 不会调用 hydrate 相关的东西tryToClaimNextHydratableInstance(workInProgress);}// 获取type和props, 对于 HostComponent 没有 state的概念const type = workInProgress.type;const nextProps = workInProgress.pendingProps;const prevProps = current !== null ? current.memoizedProps : null;let nextChildren = nextProps.children;const isDirectTextChild = shouldSetTextContent(type, nextProps); // 获取该节点是否是 纯字符串if (isDirectTextChild) {// We special case a direct text child of a host node. This is a common// case. We won't handle it as a reified child. We will instead handle// this in the host environment that also have access to this prop. That// avoids allocating another HostText fiber and traversing it.nextChildren = null;} else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {// If we're switching from a direct text child to a normal child, or to// empty, we need to schedule the text content to be reset.// 之前props存在,并且也是文本,则重新设置 tagworkInProgress.effectTag |= ContentReset;}// 在 class component 和 host component 都有这个// 在 class component 是有 instance// 在 dom 节点,也有 instance// 对应这两种节点才能拿到 ref, 否则没有引用markRef(current, workInProgress);// Check the host config to see if the children are offscreen/hidden.// 符合 下面这种情况,其中 当前的更新的优先级不为 Never, workInProgress.mode 要符合 ConcurrentMode 并且 设置了 hidden// 比如模拟自定义的滑动,浏览器的滚动条,通过这个属性来进行一个优化,把不需要显示的组件设置为 hidden// 这样每次滑动,就不需要更新这个组件,减少损耗性能if (renderExpirationTime !== Never &&workInProgress.mode & ConcurrentMode &&shouldDeprioritizeSubtree(type, nextProps)) {// Schedule this fiber to re-render at offscreen priority. Then bailout.workInProgress.expirationTime = Never; // 设置成 Never 这个节点将永不会更新到return null;}// 调用来创建,调和子节点reconcileChildren(current,workInProgress,nextChildren,renderExpirationTime,);return workInProgress.child;
}
  • 进入 shouldSetTextContent

    • 来自于 packages/react-reconciler/src/ReactFiberHostConfig.js 这里打包对应的是
      • 这里根据不同平台指向不同的js
    • packages/react-reconciler/src/forks/ReactFiberHostConfig.dom.js 看到
      export * from 'react-dom/src/client/ReactDOMHostConfig';
      
    • 定位到 react-dom/src/client/ReactDOMHostConfig.js 中
      export function shouldSetTextContent(type: string, props: Props): boolean {return (type === 'textarea' ||type === 'option' ||type === 'noscript' ||typeof props.children === 'string' ||typeof props.children === 'number' ||(typeof props.dangerouslySetInnerHTML === 'object' &&props.dangerouslySetInnerHTML !== null &&props.dangerouslySetInnerHTML.__html != null));
      }
      
      • 基于此来确定是否继续调和子节点
      • 因为, textarea, option, noscript 这种内部只能显示字符串,里面放新节点没有任何意义
      • string和number是在一个dom节点内的内容
      • 如果有 dangerouslySetInnerHTML 相关也是一个特殊情况
  • 进入 shouldDeprioritizeSubtree

    // packages/react-dom/src/client/ReactDOMHostConfig.js
    export function shouldDeprioritizeSubtree(type: string, props: Props): boolean {return !!props.hidden;
    }
    

定位到 packages/react-reconciler/src/ReactFiberBeginWork.js#L733
进入 updateHostText 这个API

function updateHostText(current, workInProgress) {// 跳过 hydrate 过程if (current === null) {tryToClaimNextHydratableInstance(workInProgress);}// Nothing to do here. This is terminal. We'll do the completion step// immediately after.return null;
}
  • 对于 HostText 来说,不可能有子节点的,不需要调用 reconcileChildren
  • 真正被插入dom里面要等到后期完成树渲染进行commit时才会放进去
  • 在 update 的过程中,不涉及dom操作, 在completeUnitOfWork 时才会去更新dom
http://www.tj-hxxt.cn/news/32405.html

相关文章:

  • 微信网站域名备案成功后怎么做推广平台 赚佣金
  • 宁波专业平台网站建设网络推广的优化服务
  • 沈阳微信网站开发站长工具爱站
  • 东莞大岭山做网站公司企业品牌类网站有哪些
  • 北京摇号网站维护广州网站推广联盟
  • 做网站有自己的服务器吗seo也成搜索引擎优化
  • 关于做香奈儿网站的PPT公司宣传软文
  • 电脑在哪里制作网站营销推广方案怎么写
  • 某企业网站网页设计模板竞价推广营销
  • 代码生成器在线衡阳seo优化报价
  • 王野天女演员葛优照片搜索引擎优化方法与技巧
  • 番禺低价网站建设电视剧百度搜索风云榜
  • 近的网站在线客服系统泰安做网站公司哪家比较好
  • 深圳宝安网站推广适合员工的培训课程
  • wordpress分类目录title2020 惠州seo服务
  • 石岩附近做网站公司湖北荆门今日头条
  • 点开图片跳到网站怎么做产品如何做线上推广
  • 佛山网站制作做多少钱企业管理培训
  • 做阿胶上什么网站比较好万网域名注册信息查询
  • 做网站流程seo全称英文怎么说
  • 网站后台左侧导航折叠效果打不开站长工具查询seo
  • 做爰全过程网站免费的视频兰州seo优化公司
  • 深圳市网站备案需求百度一下百度主页
  • 国外设计案例网站项目营销推广策划
  • 石家庄外贸网站制作网站建设知名公司
  • 江苏连云港最新疫情广州seo网站推广公司
  • 微信微网站怎么进入生成关键词的软件免费
  • 做网站认证违法吗营销策略的思路
  • 网站开发属于商标哪个类别朔州seo
  • DW建设网站过程中出现的问题网络视频营销平台