给特宝网站商家网址怎样做网站企业建设

news/2025/10/8 15:07:29/文章来源:
给特宝网站商家网址怎样做,网站企业建设,WordPress文章彩色标签,贵阳建网站beginWork 1 #xff09;概述 在 renderRoot 之后#xff0c;要对我们的 Fiber 树每一个节点进行对应的更新更新节点的一个入口方法#xff0c;就是 beginWork这个入口方法会有帮助我们去优化整棵树的更新过程 react 它的节点其实是非常多的#xff0c;如果每一次子节点的…beginWork 1 概述 在 renderRoot 之后要对我们的 Fiber 树每一个节点进行对应的更新更新节点的一个入口方法就是 beginWork这个入口方法会有帮助我们去优化整棵树的更新过程 react 它的节点其实是非常多的如果每一次子节点的一个更新就需要每一个节点都执行一遍更新的话它整体的性能肯定会不好而且是没有必要的我们一个子节点的更新可能不会影响到它的兄弟节点的更新所以这部分肯定是要优化的 具体它是如何进行优化的如下 首先要判断组件的更新是否可以优化然后要根据节点的类型分发进行处理每一个节点它的更新方式会不一样最后是要根据 expirationTime 等信息判断这个节点的更新是否可以跳过 2 源码 在 renderRoot 中它里面调用一个方法叫做 workLoop在 workLoop 中调用的一个方法叫做 performUnitOfWork而 beginWork 方法就在 performUnitOfWork 中调用beginWork 就是执行对整棵树的每一个节点进行更新的一个操作beginWork 来自于import {beginWork} from ./ReactFiberBeginWork;定位到 packages/react-reconciler/src/ReactFiberBeginWork.js 整个文件 export 出去的只有 beginWork 方法 function beginWork(current: Fiber | null,workInProgress: Fiber,renderExpirationTime: ExpirationTime, ): Fiber | null {// 读取了 workInProgress.expirationTime 这个值这个 expirationTime 是节点上的 expirationTime// 函数第三个参数 renderExpirationTime 是 nextExpirationTimeToWorkOn 和 下面这个 expirationTime 有区别const updateExpirationTime workInProgress.expirationTime;// 在 ReactDOM.render 第一次渲染时第一个节点 current 是有值的, 接下去的节点都是没有的// 因为我们操作都是在 workInProgress 上操作的// 所以workInProgress 创建的 child 节点也是一个 workInProgress 而不是 current// performUnitOfWork 接收的就是 workInProgressif (current ! null) {const oldProps current.memoizedProps;const newProps workInProgress.pendingProps;// 下面 renderExpirationTime 标志优先级最大都到哪个点如果节点上的 expirationTime 比 renderExpirationTime 小// 说明节点上有优先级更高的任务在这次渲染里是会执行的反之则不需要进行渲染这个节点可以跳过// (updateExpirationTime NoWork || updateExpirationTime renderExpirationTime) 代表没有更新 或 有更新但是优先级不高// hasLegacyContextChanged 属 context 相关api, childContextType 先跳过// oldProps newProps 表示 props 一样if (oldProps newProps !hasLegacyContextChanged() (updateExpirationTime NoWork ||updateExpirationTime renderExpirationTime)) {// This fiber does not have any pending work. Bailout without entering// the begin phase. Theres still some bookkeeping we that needs to be done// in this optimized path, mostly pushing stuff onto the stack.// switch 先跳过switch (workInProgress.tag) {case HostRoot:pushHostRootContext(workInProgress);resetHydrationState();break;case HostComponent:pushHostContext(workInProgress);break;case ClassComponent: {const Component workInProgress.type;if (isLegacyContextProvider(Component)) {pushLegacyContextProvider(workInProgress);}break;}case HostPortal:pushHostContainer(workInProgress,workInProgress.stateNode.containerInfo,);break;case ContextProvider: {const newValue workInProgress.memoizedProps.value;pushProvider(workInProgress, newValue);break;}case Profiler:if (enableProfilerTimer) {workInProgress.effectTag | Update;}break;case SuspenseComponent: {const state: SuspenseState | null workInProgress.memoizedState;const didTimeout state ! null state.didTimeout;if (didTimeout) {// If this boundary is currently timed out, we need to decide// whether to retry the primary children, or to skip over it and// go straight to the fallback. Check the priority of the primary// child fragment.const primaryChildFragment: Fiber (workInProgress.child: any);const primaryChildExpirationTime primaryChildFragment.childExpirationTime;if (primaryChildExpirationTime ! NoWork primaryChildExpirationTime renderExpirationTime) {// The primary children have pending work. Use the normal path// to attempt to render the primary children again.return updateSuspenseComponent(current,workInProgress,renderExpirationTime,);} else {// The primary children do not have pending work with sufficient// priority. Bailout.const child bailoutOnAlreadyFinishedWork(current,workInProgress,renderExpirationTime,);if (child ! null) {// The fallback children have pending work. Skip over the// primary children and work on the fallback.return child.sibling;} else {return null;}}}break;}}// 这个方法跳过该节点与其所有子节点的更新return bailoutOnAlreadyFinishedWork(current,workInProgress,renderExpirationTime,);}}// Before entering the begin phase, clear the expiration time.workInProgress.expirationTime NoWork;switch (workInProgress.tag) {case IndeterminateComponent: {const elementType workInProgress.elementType;return mountIndeterminateComponent(current,workInProgress,elementType,renderExpirationTime,);}case LazyComponent: {const elementType workInProgress.elementType;return mountLazyComponent(current,workInProgress,elementType,updateExpirationTime,renderExpirationTime,);}case FunctionComponent: {const Component workInProgress.type;const unresolvedProps workInProgress.pendingProps;const resolvedProps workInProgress.elementType Component? unresolvedProps: resolveDefaultProps(Component, unresolvedProps);return updateFunctionComponent(current,workInProgress,Component,resolvedProps,renderExpirationTime,);}case ClassComponent: {const Component workInProgress.type;const unresolvedProps workInProgress.pendingProps;const resolvedProps workInProgress.elementType Component? unresolvedProps: resolveDefaultProps(Component, unresolvedProps);return updateClassComponent(current,workInProgress,Component,resolvedProps,renderExpirationTime,);}case HostRoot:return updateHostRoot(current, workInProgress, renderExpirationTime);case HostComponent:return updateHostComponent(current, workInProgress, renderExpirationTime);case HostText:return updateHostText(current, workInProgress);case SuspenseComponent:return updateSuspenseComponent(current,workInProgress,renderExpirationTime,);case HostPortal:return updatePortalComponent(current,workInProgress,renderExpirationTime,);case ForwardRef: {const type workInProgress.type;const unresolvedProps workInProgress.pendingProps;const resolvedProps workInProgress.elementType type? unresolvedProps: resolveDefaultProps(type, unresolvedProps);return updateForwardRef(current,workInProgress,type,resolvedProps,renderExpirationTime,);}case Fragment:return updateFragment(current, workInProgress, renderExpirationTime);case Mode:return updateMode(current, workInProgress, renderExpirationTime);case Profiler:return updateProfiler(current, workInProgress, renderExpirationTime);case ContextProvider:return updateContextProvider(current,workInProgress,renderExpirationTime,);case ContextConsumer:return updateContextConsumer(current,workInProgress,renderExpirationTime,);case MemoComponent: {const type workInProgress.type;const unresolvedProps workInProgress.pendingProps;const resolvedProps resolveDefaultProps(type.type, unresolvedProps);return updateMemoComponent(current,workInProgress,type,resolvedProps,updateExpirationTime,renderExpirationTime,);}case SimpleMemoComponent: {return updateSimpleMemoComponent(current,workInProgress,workInProgress.type,workInProgress.pendingProps,updateExpirationTime,renderExpirationTime,);}case IncompleteClassComponent: {const Component workInProgress.type;const unresolvedProps workInProgress.pendingProps;const resolvedProps workInProgress.elementType Component? unresolvedProps: resolveDefaultProps(Component, unresolvedProps);return mountIncompleteClassComponent(current,workInProgress,Component,resolvedProps,renderExpirationTime,);}default:invariant(false,Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.,);} }注意最顶层 workInProgress.expirationTime; 这个 expirationTime Fiber 节点上的 expirationTime 对比 ReactFiberScheduler.js 中的 renderRoot 中读取的 root.nextExpirationTimeToWorkOn这个 root 是 FiberRoot, 而 FiberRoot 对应的 Fiber对象是 RootFiberRootFiber 是 FiberRoot 的 current 属性它没有对应React组件树的任何节点, 它只对应 FiberRoot 节点 FiberRoot 节点也就是挂载整个应用到的 Dom 节点FiberRoot 上面存储整个应用的 expirationTime 和 RootFiber 的 stateNode 属性是 FiberRootFiberRoot 上面会存储整个应用上面的 expirationTime 和 nextExpirationTimeToWorkOn上面的两个值意义是不一样的, 在 renderRoot 函数中的一段代码如下// Reset the stack and start working from the root. resetStack(); nextRoot root; nextRenderExpirationTime expirationTime; // nextUnitOfWork 是一个Fiber对象, 对应 RootFiber, 而非 FiberRoot // 更新过程使用的都是 Fiber 对象不会是 FiberRoot nextUnitOfWork createWorkInProgress(nextRoot.current, // 注意这里null,nextRenderExpirationTime, );nextUnitOfWork 才是我们每一个节点去更新时要操作的节点对象 所以workInProgress.expirationTime 是对应Fiber节点产生更新的过期时间 这里页面点击按钮让某个组件更新最多到App上面创建更新不可能到 RootFiber 上面创建更新 而 RootFiber 产生更新时在 ReactDOM.render 的时候才会有注意在 beginWork 第一个参数是 current 是 Fiber对象它对应的tag是 HostRoot 在创建 FibeRoot 时, 在 ReactFiberReconciler.js 中的 createContainer 中有一个方法叫做 createFiberRoot, 定位到 ReactFiberRoot.js 中定位到 createHostRootFiber 方法而这个方法又来自于 ReactFiber.js找到 createFiber, 是最终创建Fiber对象的时候调用的方法return createFiber(HostRoot, null, null, mode);参数是 HostRoot, null, null, mode第一个参数 HostRoot 就是 Fiber的tag 在 ReactFiberScheduler.js 中 performUnitOfWork 接收的就是一个 workInProgress 它传给 beginWork 的第一个参数 current 是 workInProgress.alternate在第一次渲染也就是 ReactDOM.render 的时候, workInProgress 是刚刚创建的是不会在创建一个 current, 要等渲染结束后把 current 和 workInProgress 的指针进行一个调换它才会变成有 current, 没有 workInProgress再下次有更新产生进行渲染时才会创建一个新的 workInProgress这时候current 和 workInProgress 都有了在最顶层 判断 current 是否 为 null, 也就是 判断是否是第一次渲染 关于 bailoutOnAlreadyFinishedWork 这个方法帮助跳过该节点与其所有子节点的更新function bailoutOnAlreadyFinishedWork(current: Fiber | null,workInProgress: Fiber,renderExpirationTime: ExpirationTime, ): Fiber | null {cancelWorkTimer(workInProgress);if (current ! null) {// Reuse previous context listworkInProgress.firstContextDependency current.firstContextDependency;}if (enableProfilerTimer) {// Dont update base render times for bailouts.stopProfilerTimerIfRunning(workInProgress);}// Check if the children have any pending work.const childExpirationTime workInProgress.childExpirationTime; // 这个值是 React 16.5 加上的更早跳过更新// 子树上无更新或高优先级任务在这次渲染中完成的 则跳过是一个非常大的优化if (childExpirationTime NoWork ||childExpirationTime renderExpirationTime) {// The children dont have any work either. We can skip them.// TODO: Once we add back resuming, we should check if the children are// a work-in-progress set. If so, we need to transfer their effects.return null;} else {// This fiber doesnt have work, but its subtree does. Clone the child// fibers and continue.// 如果子树上有更新要执行拷贝老的childcloneChildFibers(current, workInProgress);return workInProgress.child;} }回过头看 performUnitOfWork, return 了 child 之后赋值给nextlet next; if (enableProfilerTimer) {// ... 跳过很多代码next beginWork(current, workInProgress, nextRenderExpirationTime);// ... 跳过很多代码 } else {next beginWork(current, workInProgress, nextRenderExpirationTime);workInProgress.memoizedProps workInProgress.pendingProps; }// ... 跳过很多代码if (next null) {// If this doesnt spawn new work, complete the current work.next completeUnitOfWork(workInProgress); }ReactCurrentOwner.current null; // next 不为 null, 直接 return return next;return next; 之后 回调 workLoop, 之后赋值给 nextUnitOfWorkwhile (nextUnitOfWork ! null) {nextUnitOfWork performUnitOfWork(nextUnitOfWork);}通过 while 循环继续执行 child 的更新

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/931636.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

网站推广的方式和方法常见的微网站平台有哪些方面

文章目录 linux软件安装linux系统部署liunx升级linux常见故障及排查思路概要 1. Linux软件安装 软件包管理:Linux系统通常使用包管理工具(如APT、YUM、DNF等)来简化软件安装和管理。用户可以通过命令行快速安装、卸载和更新软件包。源配置:确保软件源(repository)正确配…

2025 年太阳能路灯厂商最新推荐榜:聚焦优质企业,从技术实力到合作案例全方位解析太阳能道路灯/景观灯/警示灯/庭院灯/草坪灯/杀虫灯厂家推荐

随着新能源政策大力推进与绿色基建需求持续攀升,太阳能路灯行业迎来发展机遇,但市场问题也随之凸显。部分产品存在太阳能板转换效率低、电池续航不足等缺陷,阴雨天气易出现照明中断;不少厂商缺乏核心技术,仅靠组装…

Luogu P11660 我终将成为你的倒影 题解 [ 紫 ] [ 分块 ] [ 分类讨论 }

我终将成为你的倒影:考察分块基本功的一道题。 注意到本题强制在线,且这种信息用线段树不是很好维护,所以可以很自然地想到分块。 又注意到 \(b \le 500\),所以考虑暴力枚举 \(b\)。发现当 \(b\) 固定的时候,\(a\…

免费的企业网站cms百度指数明星人气榜

1、SpringCloud是什么? 1、 Spring Cloud是一系列框架的有序集合。它利用SpringBoot的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册、配置中心、智能路由、消息总线、负载均衡、断路器、数据监控等,都可以用SpringBoot的…

网站目的及功能定位深圳网站优化哪家好

目录 101.RocketMQ的事务消息是如何实现的 102.为什么RocketMQ不使⽤Zookeeper作为注册中⼼呢? 103.RocketMQ的实现原理 104.RocketMQ为什么速度快 105.消息队列如何保证消息可靠传输 106.消息队列有哪些作⽤ 107.死信队列是什么?延时队列是什么&a…

2025 年最新推荐!小程序开发机构排行榜:覆盖定制开发 / 电商 / 预订 / 配送多场景优质服务商成都小程序开发/小程序定制开发/电商小程序开发/预订服务小程序开发公司推荐

在数字化转型浪潮下,小程序已成为政企打通线上服务、提升运营效率的关键工具,但其开发市场却乱象丛生。不少厂商以模板套用冒充定制开发,导致交付后功能与需求脱节、二次开发受阻;部分服务商技术迭代缓慢,开发的小…

CF280D k-Maximum Subsequence Sum 题解(线段树+反悔贪心维护k段最大子段和)

线段树维护区间最大子段和是好做的:每个节点维护当前最大子段和、从左端点开始的最大子段和、从右端点开始的最大子段和、当前节点的和。 这个题允许我们选择最多 \(k\) 段,于是我们可以考虑一个类似于反悔贪心的做法…

深圳网站优化公司哪家好wap建站程序合集

博客主页:誓则盟约系列专栏:IT竞赛 专栏关注博主,后期持续更新系列文章如果有错误感谢请大家批评指出,及时修改感谢大家点赞👍收藏⭐评论✍ 蓝桥第14场小白入门赛T1/T2/T3 题目: T1照常还是送分题无需多…

做网站要分几部分完成广东网站建设方便

一、项目介绍 在游乐场、商场、景区等人流量较大的地方,往往存在用户需要临时存放物品的情况,例如行李箱、外套、购物袋等。为了满足用户的储物需求,并提供更加便捷的服务体验,当前设计了一款物联网智能储物柜。 该智能储物柜通…

2025年微信小程序开发:趋势、最佳实践与AI整合 - 指南

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

网站点击率怎么建西安做公司网站

STM32G4系列单片机,为32位的微控制器,理论上其内部寄存器地址最多支持4GB的命名及查找(2的32次方,地址命名为0x00000000至0xFFFFFFFF)。STM32官方对4GB的地址存储进行编号时,又分割成了8个block区域&#x…

网站有哪几种类型做网站 华普花园

会计学专业学什么 会计学专业属于工商管理学科下的一个二级学科,本专业培养具备财务、管理、经济、法律等方面的知识和能力,具有分析和解决财务、金融问题的基本能力,能在企、事业单位及政府部门从事会计实务以及教学、科研方面工作的工商管…

实验课1

实验1源代码1 #include<stdio.h> 2 int main() 3 { 4 printf(" o\n"); 5 printf("<H>\n"); 6 printf("I I\n"); 7 8 return 0; 9 } View Code运行…

做自我介绍的网站的图片素材怎么用动图做网站背景

Description Input 第一行为两个整数n, m。第二行有n个整数&#xff0c;为a1&#xff0c;a2, …, an。 Output 包含n行&#xff0c;每行m个1~nm的正整数&#xff0c;各不相同&#xff0c;以空格分开。如果有多解&#xff0c;输出任意一组解&#xff1b;如果无解&#xff0c;输出…

深入解析:【LeetCode 热题100】回溯:括号生成 组合总和(力扣22 / 39 )(Go语言版)

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

完整教程:基于 COM 的 XML 解析技术(MSXML) 的总结

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

asp网站开发需要什么网站建设 企业文化

来源&#xff1a;ScienceAI编辑&#xff1a;萝卜皮人类的大部分细胞中&#xff0c;每时每刻都在进行着各种复杂的转录过程&#xff1b;这一过程与后续的蛋白质合成息息相关&#xff0c;从而会影响人体中各类酶、抗体、激素、免疫因子等生物分子的产生&#xff0c;最终影响人的身…

详细介绍:Windows如何定制键盘按键

详细介绍:Windows如何定制键盘按键pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco…

台州网站建设系统江苏网站建设电话

要搭建一个标准的测量系统,需要考虑以下几个方面: 确定测量目的和需求:首先需要明确测量的目的和需求,例如测量长度、重量、体积等。同时需要考虑测量的精度和误差范围,以及测量系统的适用范围和条件等。选择合适的传感器:根据测量目的和需求,选择合适的传感器类型,例如…

TheHackersLabs Templo writeup

信息收集 nmap获取userFlag 去web看一下web上只有一个默认的index.html,通过gobuster扫一下目录 gobuster dir -u http://192.168.43.208/ -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt 有一个w…