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

怀化网站制作网站建设布局利于优化

怀化网站制作,网站建设布局利于优化,美团后台管理系统登录,慢慢网站建设HostRoot 的更新 1 #xff09;概述 HostRoot 是一个比较特殊的节点, 因为在一个react应用当中它只会有一个 HostRoot, 它对应的 Fiber 对象是我们的 RootFiber 对象重点在于它的更新过程 2 #xff09;源码 定位到 packages/react-reconciler/src/ReactFiberBeginWork.js…HostRoot 的更新 1 概述 HostRoot 是一个比较特殊的节点, 因为在一个react应用当中它只会有一个 HostRoot, 它对应的 Fiber 对象是我们的 RootFiber 对象重点在于它的更新过程 2 源码 定位到 packages/react-reconciler/src/ReactFiberBeginWork.js#L612 // 这个函数的重点在: update 来自哪里, 里面是什么内容 // 最终通过 processUpdateQueue 得到了 element 里面的内容之后以此作为children来调和 function updateHostRoot(current, workInProgress, renderExpirationTime) {// 跳过 context 相关pushHostRootContext(workInProgress);const updateQueue workInProgress.updateQueue;invariant(updateQueue ! null,If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.,);// 获取一系列数据const nextProps workInProgress.pendingProps;const prevState workInProgress.memoizedState;// 对于 HostRoot 一开始是没有 state也就是 prevState.element, 在第一次渲染的时候prevState 是 null在ReactDOM.render中创建了一个update// 经过 processUpdateQueue 这次更新后它会拿到一个 {element} 对象作为 stateconst prevChildren prevState ! null ? prevState.element : null;// 得到创建的update传递的elementprocessUpdateQueue(workInProgress,updateQueue,nextProps,null,renderExpirationTime,);const nextState workInProgress.memoizedState;// Caution: React DevTools currently depends on this property// being called element.const nextChildren nextState.element;if (nextChildren prevChildren) {// If the state is the same as before, thats a bailout because we had// no work that expires at this time.resetHydrationState(); // 服务端渲染复用dom节点相关内容// 跳出更新过程不需要更新// 对 RootFiber来说大部分情况下只在 ReactDOM.render 的时候有更新其他时候都不需要更新// 一般都是在App内更新不会在RootFiber节点创建更新return bailoutOnAlreadyFinishedWork(current,workInProgress,renderExpirationTime,);}const root: FiberRoot workInProgress.stateNode;// 跳过 hydrate 相关if ((current null || current.child null) root.hydrate enterHydrationState(workInProgress)) {// If we dont have any current children this might be the first pass.// We always try to hydrate. If this isnt a hydration pass there wont// be any children to hydrate which is effectively the same thing as// not hydrating.// This is a bit of a hack. We track the host root as a placement to// know that were currently in a mounting state. That way isMounted// works as expected. We must reset this before committing.// TODO: Delete this when we delete isMounted and findDOMNode.workInProgress.effectTag | Placement;// Ensure that children mount into this root without tracking// side-effects. This ensures that we dont store Placement effects on// nodes that will be hydrated.// 在 current null || current.child null 这种情况下都是第一次渲染workInProgress.child mountChildFibers(workInProgress,null,nextChildren,renderExpirationTime,);} else {// Otherwise reset hydration state in case we aborted and resumed another// root.// 不是第一次渲染reconcileChildren(current,workInProgress,nextChildren,renderExpirationTime,);resetHydrationState();}return workInProgress.child; }HostRoot 创建更新的过程就是在 ReactFiberReconciler.js 中的调用 ReactDOM.render 的过程定位到 scheduleRootUpdate 位置在 packages/react-reconciler/src/ReactFiberReconciler.js#L110function scheduleRootUpdate(current: Fiber,element: ReactNodeList,expirationTime: ExpirationTime,callback: ?Function, ) {// ... 省略const update createUpdate(expirationTime);update.payload {element};// ... 省略return expirationTime; }它这里创建一个 update, 并挂在 update.payload 是 {element}这个 element 就是传给 ReactDOM.render 的第一个参数这个 update 对象没有后续指定类型这和调用 setState 在组件内创建更新效果是类似的所以update.payload 就相当于 state对于 HostRoot 来说, 它的state只有一个属性就是element就是 ReactDOM.render 的第一个参数
http://www.hkea.cn/news/14371164/

相关文章:

  • 纯html5网站建设网站后如何做后台
  • 个人什么取消网站备案设计微信小程序多少钱
  • 网上有哪些购物网站营销引流100个技巧
  • 广东省住建厅官方网站余干县建设局网站
  • 建网站 陕西牛人网络科技下载男女做爰免费网站
  • wordpress网站测速windows优化大师的特点
  • 湘潭做网站 搜搜磐石网络天眼查官网在线查询
  • 厦门网站建设公司电话如何买域名发布网站
  • 怎样用模板建网站网站流量到底怎样赚钱的
  • 做公章网站怎样在手机上建设网站
  • 网站服务器建设软件可以直接打开网站的方法
  • 清河企业做网站网站管理过程
  • 淄企业网站建设公司百度指数是什么意思
  • 合肥网站建设技术上海最近出啥事了
  • 平阳住房和城乡建设厅网站单产品网站建设
  • 做公司网站要什么资料wordpress中文企业模板下载
  • 网站开发需求烈焰传奇网页版
  • 湖南建设资质申请网站无锡企业推广
  • 给公司做网站 优帮云ps做网站的时候分辨率是
  • 广州网站建设公司乐云seo598吴江高端网站建设
  • 网站的根目录中九江市金融控股集团有限公司
  • 企业网站维护工作内容江门网红打卡景点蓬江区
  • 东莞网站推广排名wordpress_广告主题
  • 网站程上传wordpress如何知道用户数量
  • 新建网站怎样绑定域名wordpress 迁移 插件
  • asp网站背景专业网站建设流程
  • 新乡网站建设官网手机网站管理软件
  • 网站设计方法中国建筑app下载官网
  • 网站服务器中如何做重定向门户网站含义
  • iis6建设网站信誉好的做网站公司