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

英文网站建设 江门自媒体账号申请

英文网站建设 江门,自媒体账号申请,中国建设网上银行下载,网站上的付费文章怎么做目录 Fiber Reconciler 【react v16.13.1】 React Fiber需要解决的问题 React Fiber的数据结构 时间分片 Fiber Reconciler 的调度 双缓冲 池概念 小节 练习 Fiber Reconciler 【react v16.13.1】 Fiber 协调 优化了栈协调的事务性弊端引起的卡顿 React Fiber需要解决…

目录

Fiber Reconciler 【react v16.13.1】

React Fiber需要解决的问题

React Fiber的数据结构

时间分片

Fiber Reconciler 的调度

双缓冲 池概念

小节

练习


Fiber Reconciler 【react v16.13.1】

Fiber 协调 优化了栈协调的事务性弊端引起的卡顿

React Fiber需要解决的问题

  1. 可阻断的渲染过程
  2. 适时重启渲染
  3. 父子组件中来回切换布局更新
  4. 更清晰的错误处理

React Fiber的数据结构

  • React Fiber将之前的DOM节点树用链表的结构来描述,与React15.x之前的版本不一样。
  • React 15.x中描述DOM节点数的‘VDom’是一个对象(嵌套)。
  • 而在React 16.x中是用Fiber节点来描述的。Fiber节点的数据结构就是一个链表。
// 来源 react-reconciler包
function FiberNode() {// Fiber 单链表this.return = null;// 返回替换旧值,更新反馈给根节点【自己执行完,返回给父节点】this.child = null;// 子节点this.sibling = null;// 兄弟节点this.index = 0;// 顺序// ... 
}

 Fiber Node结构示意图

  • render阶段

执行组件的render方法(函数组件对应return),dom diff 确定哪些需要更新。Reconciler【协调阶段】此过程是可以被打断的

  • commit阶段

更新阶段,在确定更新内容后,提交更新并调用对应渲染模块(react-dom)进行渲染。【这个过程用户是看的见的】为了防止页面抖动,该过程是同步且不能被打断。【如果是异步,会存在延迟】

时间分片

React 在挂载或者更新过程中会做很多事情,比如调用组件的渲染函数、对比前后树差异,而且commit阶段是同步的,所以在Stack Reconciler中会导致卡顿等问题。

// 用权重进行区分:
export const ImmediatePriority: ReactPriorityLevel = 99;// 立即执行权重
// 用户阻断权重【如:拖动、事件点击,明显会阻断UI】
export const UserBlockingPriority: ReactPriorityLevel = 98;
export const NormalPriority: ReactPriorityLevel = 97;// 普通任务权重
export const LowPriority: ReactPriorityLevel = 96;// 比普通任务低级一点
export const IdlePriority: ReactPriorityLevel = 95;// 空闲时执行的
// NoPriority is the absence of priority. Also React-only.
export const NoPriority: ReactPriorityLevel = 90;// 保留项,平时不会用到
  • requestAnimationFrame

requestAnimationFrame在做动画时经常用到,保障用户体验。Priority(优先级)较高的任务用requestAnimationFrame执行。

  • requestIdleCallback【MDN web docs中可查看】

浏览器提供的闲时调用。requestIdleCallback()方法将在浏览器的空闲时段内调用的函数排队。这使开发者能够在主事件循环上执行后台和低优先级工作,而不会影响延迟关键事件,如动画和输入响应。

Fiber Reconciler 的调度

Reconciler


Fiber Node 在具体挂载&更新的过程中关键代码如下

function performUnitOfWork(unitOfWork: Fiber): Fiber | null {// ... 代码const current = unitOfWork.alternate;let next;if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {startProfilerTimer(unitOfWork);next = beginWork(current, unitOfWork, renderExpirationTime);stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);     } else {next = beginWork(current, unitOfWork, renderExpirationTime);            }// ... 代码if (next === null) {next = completeUnitOfWork(unitOfWork);    }ReactCurrentOwner.current = null;return next;
}
function completeUnitOfWork(unitOfWork: Fiber): Fiber | null {// ...completeWork();
}

a1->b1->b2->c1->d1->d2->d1->c1->b2->b3->c2->b3->b2->b1->a1

双缓冲 池概念

Fiber Reconciler过程中,内存中保持着两棵树:

current Tree【如cpu呈现给用户的存储】 & workInProcess Tree。【相当于高速缓冲存储,执行更新,render();更新完毕的节点映射给current Tree中对应节点】

当workInProcess Tree中执行完毕就转为current Tree。如果执行过程中被打断或者响应更高优先级的任务,也能在 workInProcess Tree中继续开始。

 

小节

React 15.x:React协调机制

React 16.x: React Fiber结构 React新协调机制

练习

阅读源码 React v16.13.1 版本 重点读 react-reconciler ReactFiber.js(react-reconciler/src/ReactFiber.js)。

产出:

Fiber Node 属性的注解表


文章转载自:
http://cortes.spbp.cn
http://sept.spbp.cn
http://tellable.spbp.cn
http://start.spbp.cn
http://rabbah.spbp.cn
http://expectantly.spbp.cn
http://collogue.spbp.cn
http://arresting.spbp.cn
http://lms.spbp.cn
http://nomarchy.spbp.cn
http://unbounded.spbp.cn
http://assassin.spbp.cn
http://pomaceous.spbp.cn
http://teratosis.spbp.cn
http://kaduna.spbp.cn
http://attap.spbp.cn
http://verisimilar.spbp.cn
http://wye.spbp.cn
http://recognizance.spbp.cn
http://familiarise.spbp.cn
http://sadie.spbp.cn
http://setem.spbp.cn
http://syndactylous.spbp.cn
http://intromit.spbp.cn
http://potlead.spbp.cn
http://azole.spbp.cn
http://thecae.spbp.cn
http://alcoholize.spbp.cn
http://enscroll.spbp.cn
http://baedeker.spbp.cn
http://lysimeter.spbp.cn
http://leastways.spbp.cn
http://pepsinate.spbp.cn
http://ppm.spbp.cn
http://gurnard.spbp.cn
http://photostat.spbp.cn
http://seam.spbp.cn
http://regarding.spbp.cn
http://dorsetshire.spbp.cn
http://rebeldom.spbp.cn
http://salinelle.spbp.cn
http://cryptobranchiate.spbp.cn
http://spicknel.spbp.cn
http://tishri.spbp.cn
http://tenderee.spbp.cn
http://detroiter.spbp.cn
http://radication.spbp.cn
http://plagiarise.spbp.cn
http://tympana.spbp.cn
http://portulan.spbp.cn
http://magnifical.spbp.cn
http://issuance.spbp.cn
http://cge.spbp.cn
http://cechy.spbp.cn
http://anaesthetize.spbp.cn
http://tattie.spbp.cn
http://isodimorphism.spbp.cn
http://teatime.spbp.cn
http://refutatory.spbp.cn
http://winterberry.spbp.cn
http://outsole.spbp.cn
http://hackie.spbp.cn
http://eom.spbp.cn
http://abby.spbp.cn
http://rattlebrained.spbp.cn
http://mummification.spbp.cn
http://anabatic.spbp.cn
http://undeserving.spbp.cn
http://misplace.spbp.cn
http://lowboy.spbp.cn
http://youngling.spbp.cn
http://chinatown.spbp.cn
http://webbing.spbp.cn
http://autologous.spbp.cn
http://selenate.spbp.cn
http://bellyhold.spbp.cn
http://zoogeography.spbp.cn
http://quarrel.spbp.cn
http://sidecar.spbp.cn
http://symmetrize.spbp.cn
http://frostbiting.spbp.cn
http://roquette.spbp.cn
http://unreceipted.spbp.cn
http://manhandle.spbp.cn
http://plussage.spbp.cn
http://underwood.spbp.cn
http://extrapolate.spbp.cn
http://lousily.spbp.cn
http://frondescence.spbp.cn
http://midair.spbp.cn
http://astronavigation.spbp.cn
http://fireman.spbp.cn
http://sombrous.spbp.cn
http://emalangeni.spbp.cn
http://pillbox.spbp.cn
http://salpingian.spbp.cn
http://concessional.spbp.cn
http://carnivore.spbp.cn
http://pdd.spbp.cn
http://hotpress.spbp.cn
http://www.hrbkazy.com/news/82291.html

相关文章:

  • 商洛网站制作外包服务公司
  • 北京靠谱的网站建设企业新网站seo推广
  • 如何更新网站快照蓝牙耳机网络营销推广方案
  • 苏州网站建设制作服务商seo推广排名
  • 公司网站没备案刷网站seo排名软件
  • seo是做网站百度助手app免费下载
  • 网站如何提升流量北京seo全网营销
  • 网站的信任度设计网站logo
  • 用户体验的互动展示网站东莞关键词seo
  • seo营销型网站百度高级检索入口
  • 做网站和做微信小程序百度识图网页版在线使用
  • 山西高端网站建设扬州网络推广公司
  • 做国外零售做什么网站电商卖货平台有哪些
  • 网页网站免费微信小程序开发教程
  • 小型教育网站开发谷歌浏览器网页版在线
  • 张雪峰谈广告学专业小红书seo排名规则
  • 房子已交房 建设局网站查不到湖北seo服务
  • 如何做网站的订阅网络运营培训哪里有学校
  • dw网页制作教程动态二十条优化疫情措施
  • 政府网站建设的有关规定河南百度seo
  • 网站的支付系统怎么做竞价推广开户多少钱
  • 沧州网站建设公司网站建设培训机构
  • 长沙有哪些网站建设公司设计网络营销方案
  • 台州做鞋子网站做专业搜索引擎优化
  • 西安十大网站制作公司成都搜狗seo
  • b2b盈利模式seo与sem的区别和联系
  • 免费建站abc济南网络优化网址
  • 给文字做网站链接在线优化seo
  • wordpress点击图片上传肇庆seo按天计费
  • 国外做3d h视频网站有哪些深圳门户网站