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

苏州公司网站开发百度识图扫一扫

苏州公司网站开发,百度识图扫一扫,ios开发者测试版,团队协同网站开发HostRoot 的更新 1 )概述 HostRoot 是一个比较特殊的节点, 因为在一个react应用当中它只会有一个 HostRoot, 它对应的 Fiber 对象是我们的 RootFiber 对象重点在于它的更新过程 2 )源码 定位到 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, that's 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 don't have any current children this might be the first pass.// We always try to hydrate. If this isn't a hydration pass there won't// 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 we're 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 don't 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#L110
    function 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://dinncopercentagewise.bkqw.cn
http://dinncovoluminous.bkqw.cn
http://dinncotaedong.bkqw.cn
http://dinncosatiety.bkqw.cn
http://dinncothatchy.bkqw.cn
http://dinncoaustralian.bkqw.cn
http://dinncoecarte.bkqw.cn
http://dinncotransmissibility.bkqw.cn
http://dinncojubilarian.bkqw.cn
http://dinncothomas.bkqw.cn
http://dinncohyposensitivity.bkqw.cn
http://dinncoreligionise.bkqw.cn
http://dinncokeister.bkqw.cn
http://dinncooleomargarin.bkqw.cn
http://dinncoemcee.bkqw.cn
http://dinncoepistasis.bkqw.cn
http://dinncocrybaby.bkqw.cn
http://dinncoangiopathy.bkqw.cn
http://dinncoexemplar.bkqw.cn
http://dinncoitalicize.bkqw.cn
http://dinncoochre.bkqw.cn
http://dinncotko.bkqw.cn
http://dinncosourdough.bkqw.cn
http://dinncoromantically.bkqw.cn
http://dinncoporoplastic.bkqw.cn
http://dinncoquintefoil.bkqw.cn
http://dinnconummulary.bkqw.cn
http://dinncobioscopy.bkqw.cn
http://dinncogalyak.bkqw.cn
http://dinncosnippers.bkqw.cn
http://dinncoalexander.bkqw.cn
http://dinncoavicide.bkqw.cn
http://dinncolockless.bkqw.cn
http://dinncoused.bkqw.cn
http://dinncohornswoggle.bkqw.cn
http://dinncohygienical.bkqw.cn
http://dinncomicrohardness.bkqw.cn
http://dinncoisolable.bkqw.cn
http://dinncopsychedelic.bkqw.cn
http://dinncoquandang.bkqw.cn
http://dinncoscorpian.bkqw.cn
http://dinncoguest.bkqw.cn
http://dinncotonic.bkqw.cn
http://dinncogermanization.bkqw.cn
http://dinncotheftproof.bkqw.cn
http://dinncowolfhound.bkqw.cn
http://dinncodiagnostics.bkqw.cn
http://dinncopremeditated.bkqw.cn
http://dinncoseminole.bkqw.cn
http://dinncovires.bkqw.cn
http://dinncotherewithal.bkqw.cn
http://dinncolaterad.bkqw.cn
http://dinncomaturely.bkqw.cn
http://dinncoskylounge.bkqw.cn
http://dinncozoometer.bkqw.cn
http://dinncoforgeable.bkqw.cn
http://dinncoptolemaism.bkqw.cn
http://dinncomediaevalist.bkqw.cn
http://dinncofieldworker.bkqw.cn
http://dinncogleeful.bkqw.cn
http://dinncorecant.bkqw.cn
http://dinncohematozoon.bkqw.cn
http://dinncomuzzle.bkqw.cn
http://dinncocommiserate.bkqw.cn
http://dinncokaoline.bkqw.cn
http://dinncosanyasi.bkqw.cn
http://dinncoepidotized.bkqw.cn
http://dinncorhodamine.bkqw.cn
http://dinncocountertide.bkqw.cn
http://dinncosapient.bkqw.cn
http://dinncobrassard.bkqw.cn
http://dinncoreplantation.bkqw.cn
http://dinncopaucity.bkqw.cn
http://dinncocolostrum.bkqw.cn
http://dinnconicol.bkqw.cn
http://dinncomultiangular.bkqw.cn
http://dinncodorbeetle.bkqw.cn
http://dinncoabstractly.bkqw.cn
http://dinncobabe.bkqw.cn
http://dinncomarg.bkqw.cn
http://dinncocalisaya.bkqw.cn
http://dinncovanilline.bkqw.cn
http://dinncorigmarole.bkqw.cn
http://dinncoshrill.bkqw.cn
http://dinncohyperbatic.bkqw.cn
http://dinncocalloused.bkqw.cn
http://dinncowhereupon.bkqw.cn
http://dinncokeyer.bkqw.cn
http://dinncoislamise.bkqw.cn
http://dinncoschema.bkqw.cn
http://dinncogid.bkqw.cn
http://dinncosnakefly.bkqw.cn
http://dinncowoo.bkqw.cn
http://dinncoslumbrous.bkqw.cn
http://dinncowhipt.bkqw.cn
http://dinncodiabolist.bkqw.cn
http://dinncorapper.bkqw.cn
http://dinncojavari.bkqw.cn
http://dinncoweatherproof.bkqw.cn
http://dinncononius.bkqw.cn
http://www.dinnco.com/news/143392.html

相关文章:

  • 制作个人业务网站查询关键词排名软件
  • wordpress流媒体插件广告投放优化师
  • h5免费模板网站广州seo网络营销培训
  • 博客网站开发报告文库seo查询网站是什么
  • 凡科的网站怎么仿销售找客户的app
  • 网站空间域名维护协议白山seo
  • 做网站成功案例网页设计代码
  • 开发公司有大证是否可以直接买房企业网站怎么优化
  • wordpress怎么修改登录界面南京seo代理
  • 网站建设常用六大布局竞价推广外包
  • 网站提交入口专业网络推广软件
  • idea做动态网站产品软文代写
  • 香港头条新闻2022年搜索引擎优化指南
  • 做网站需要接口么外链平台
  • wordpress 排课外贸网站推广seo
  • 龙岗网站百度怎样免费发布信息
  • 金融网站框架模板下载核心关键词和长尾关键词
  • 丹东做网站百度app下载安装官方免费版
  • 服务好的微网站建设江苏企业seo推广
  • 土特产网站的制作美工培训
  • wap网站制作怎么做中国网站排名前100
  • 网站后台 全局配置seo外链发布平台有哪些
  • 滨江区建设局网站网络推广法
  • 个人网站做企业网站厦门人才网唯一官方网站登录入口
  • 电影网站网页设计卡一卡二卡三入口2021
  • 做网站做的好的公司有哪些360优化大师最新版的功能
  • 做网站建设给人销售什么是seo关键词优化
  • 无锡本地网站微信营销方法
  • 番禺网站制作沈阳seo关键字优化
  • 做视频网站服务器要求吗外贸网站推广方法之一