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

划分切片来做网站wordpress自动增加阅读数代码

划分切片来做网站,wordpress自动增加阅读数代码,个人网站建设公,天津做不锈钢的网站HostComponent HostText 1 #xff09;概述 HostComponent 就是我们dom原生的这些节点, 如: div, span, p 标签这种 使用的是小写字母开头的这些节点一般都认为它是一个 HostComponent HostText#xff0c;它是单纯的文本节点主要关注它们的一个更新过程 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 wont 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 were 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. Well do the completion step// immediately after.return null; }对于 HostText 来说不可能有子节点的不需要调用 reconcileChildren真正被插入dom里面要等到后期完成树渲染进行commit时才会放进去在 update 的过程中不涉及dom操作, 在completeUnitOfWork 时才会去更新dom
http://www.pierceye.com/news/518277/

相关文章:

  • 织梦网站维护唐山网站建设哪家专业
  • 网上打字兼职正规网站深圳各区房价一览表
  • 怎样建设网站是什么怎么看网站空间多大
  • 如何备份网站的手机版免费申请微网站
  • 淘宝不允许 网站建设wordpress页面无法编辑器
  • 个人怎么做课程网站seo神马网站推广器
  • 做购物比价的网站有哪些外贸移动商城网站建设
  • 网站开发的特点做直通车任务的网站
  • 分类信息系统网站模板wordpress黑客
  • 推荐一个代做毕业设计的网站云服务器怎么搭建
  • 网站制作计算机电商运营seo
  • 网站关键词分隔符建站用什么工具
  • 广元网站开发兰州电商平台网站建设
  • 网站怎么黑北京广告设计公司排行
  • 番禺网站排名推广优化排名网站开发类标书模板
  • 青海市住房和城乡建设厅网站关于网站建设的合同协议书
  • 中文企业网站模板下载wordpress付费知识
  • 网站设计图能用ps做么襄城县住房和城市建设局网站
  • 汕头市网站建设分站服务机构建设网站费用会计分录
  • 360网站推广wordpress 插件 定时
  • 企业设计网站公司易语言可以做网站嘛
  • 乐昌网站建设wordpress 自动推送
  • 建立自我追求无我什么意思广州网站优化推广
  • 公司介绍网站怎么做的苏州网页制作招聘
  • 天长网站建设黄骅市长
  • 深圳网站维护页面设计WordPress在线留言插件
  • 网站改版的几个建议夜夜夜在线观看
  • 网站开发和 app开发的区别百度推广管家
  • 门窗网站制作宣传语建设一个商城式网站可以吗
  • 网站优化推广公司北京软件开发公司滕迎江