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

佛山企业网站建站wordpress访问加速

佛山企业网站建站,wordpress访问加速,最大的外包公司有哪些,重庆旅游攻略PortalComponent 1 #xff09;概述 React Portal之所以叫Portal#xff0c;因为做的就是和“传送门”一样的事情render到一个组件里面去#xff0c;实际改变的是网页上另一处的DOM结构主要关注 portal的创建, 调和, 更新过程 2 #xff09;源码 定位到 packages/react-…PortalComponent 1 概述 React Portal之所以叫Portal因为做的就是和“传送门”一样的事情render到一个组件里面去实际改变的是网页上另一处的DOM结构主要关注 portal的创建, 调和, 更新过程 2 源码 定位到 packages/react-dom/src/client/ReactDOM.js#L576 function createPortal(children: ReactNodeList,container: DOMContainer,key: ?string null, ) {invariant(isValidContainer(container),Target container is not a DOM element.,);// TODO: pass ReactDOM portal implementation as third argumentreturn ReactPortal.createPortal(children, container, null, key); } 这里调用的是 ReactPortal.createPortal, 进入 // packages/shared/ReactPortal.js#L14 export function createPortal(children: ReactNodeList,containerInfo: any,// TODO: figure out the API for cross-renderer implementation.implementation: any,key: ?string null, ): ReactPortal {return {// This tag allow us to uniquely identify this as a React Portal$$typeof: REACT_PORTAL_TYPE,key: key null ? null : key,children,containerInfo, // dom 挂载节点implementation,}; }这里返回一个对象类似于 ReactElement区别在于 $$typeof 和 containerInfo 需要的挂载点 对于 REACT_PORTAL_TYPE 类型的组件在 reconcile 时, 看下具体操作, 找到 reconcileSinglePortal // packages/react-reconciler/src/ReactChildFiber.js#L1171 function reconcileSinglePortal(returnFiber: Fiber,currentFirstChild: Fiber | null,portal: ReactPortal,expirationTime: ExpirationTime, ): Fiber {const key portal.key; // 当前的 keylet child currentFirstChild;// 如果 存在 child, 对比 child.key keywhile (child ! null) {// TODO: If key null and child.key null, then this only applies to// the first item in the list.if (child.key key) {// 关注这里有 containerInfo 的对比portal 需要关心渲染到的节点是否有变化// 如果节点有变化那么这个 portal 的渲染过程也会有变化// 都符合说明老节点都可以复用if (child.tag HostPortal child.stateNode.containerInfo portal.containerInfo child.stateNode.implementation portal.implementation) {deleteRemainingChildren(returnFiber, child.sibling); // 删除其他节点// 通过 useFiber 复用这个节点const existing useFiber(child,portal.children || [],expirationTime,);existing.return returnFiber;return existing;} else {// key相同但是不符合上述if, 没法复用删除干净deleteRemainingChildren(returnFiber, child);break;}} else {// key 不同删除当前节点deleteChild(returnFiber, child);}child child.sibling;}// 创建一个 portal 的 fiber 对象const created createFiberFromPortal(portal,returnFiber.mode,expirationTime,);created.return returnFiber;return created; }对于更新一个portal节点进入 updatePortalComponent // packages/react-reconciler/src/ReactFiberBeginWork.js#L1322 function updatePortalComponent(current: Fiber | null,workInProgress: Fiber,renderExpirationTime: ExpirationTime, ) {// 挂载点处理pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);const nextChildren workInProgress.pendingProps; // 这里 pendingProps 是 childrenif (current null) {// Portals are special because we dont append the children during mount// but at commit. Therefore we need to track insertions which the normal// flow doesnt do during mount. This doesnt happen at the root because// the root always starts with a current with a null child.// TODO: Consider unifying this with how the root works.workInProgress.child reconcileChildFibers(workInProgress,null,nextChildren,renderExpirationTime,);} else {reconcileChildren(current,workInProgress,nextChildren,renderExpirationTime,);}return workInProgress.child; }之前梳理过的 API 不再赘述一些API的调用在源码的注释中
http://www.zqtcl.cn/news/266782/

相关文章:

  • 网站改版方案案例入门级网页设计培训学员
  • 安徽优化网站运营平台
  • 小型企业网站设计教程面备案网站建设
  • 重庆业务外包网站建设办公室装修一般多少钱一个平方
  • 网站查询域名ip解析手机短视频网站的建设
  • 甘肃机械化建设工程有限公司网站微小店网站建设价格
  • 个人空间网站建设报告网络游戏交易平台
  • 深圳医疗网站建设中小企业网站功能
  • 汕头集团做网站方案建设网站要买空间吗
  • 宁波搭建网站专业展馆展厅设计公司深圳
  • 山东省建设工程电子信息网站广州开发区第一小学
  • 网站建设推广重要性河北高端网站建设
  • 网站的seo方案怎么做wordpress自动转内链
  • 番禺手机网站制作推广wordpress远程数据库
  • 企业网站seo外包 s深圳国内设计网站
  • 临海高端营销型网站建设地址免费网站alexa排名查询
  • 做企业网站的轻量级cms建设电子商务网站流程图
  • 淘宝网站设计分析国内在线免费服务器
  • wordpress网站文章加密网站建设 博采网络
  • 哪个网站做美食好一点网络运维个人工作总结
  • 做网红用哪个网站教人做策划的网站
  • 百度免费网站怎样建设wordpress模板目录结构
  • 长沙简单的网站建设公司wordpress+手机应用
  • 用spl做网站wordpress不用缓存
  • 微网站模板标签网站被攻击怎么让百度重新蜘蛛自动抓
  • 自己想做一个网站网页背景怎么设置
  • 国外做项目的网站软件定制外包平台
  • 做网站要用什么软件房地产建设网站
  • 龙岗爱联有学网站建设装饰公司简介
  • pc端网站怎么做自适应哪个公司网站备案快