React 深度学习:ReactFiberLazyComponent
path: packages/react-reconciler/src/ReactFiberLazyComponent.js
resolveDefaultProps
解析默认 props
export function resolveDefaultProps(Component: any, baseProps: Object): Object {if (Component && Component.defaultProps) {// 解析默认 props。取自 ReactElementconst props = Object.assign({}, baseProps);const defaultProps = Component.defaultProps;// 对未传入的 props 附上默认值for (let propName in defaultProps) {if (props[propName] === undefined) {props[propName] = defaultProps[propName];}}return props;}return baseProps;
}
复制代码
React 解析默认 props 的方式就是在组件上寻找是否存在 defaultProps
属性。如果存在则对它进行遍历,拷贝当前未指定的 prop。
readLazyComponentType
export function readLazyComponentType<T>(lazyComponent: LazyComponent<T>): T {const status = lazyComponent._status;const result = lazyComponent._result;switch (status) {case Resolved: {const Component: T = result;return Component;}case Rejected: {const error: mixed = result;throw error;}case Pending: {const thenable: Thenable<T, mixed> = result;throw thenable;}default: {lazyComponent._status = Pending;const ctor = lazyComponent._ctor;const thenable = ctor();thenable.then(moduleObject => {if (lazyComponent._status === Pending) {const defaultExport = moduleObject.default;if (__DEV__) {// do something}lazyComponent._status = Resolved;lazyComponent._result = defaultExport;}},error => {if (lazyComponent._status === Pending) {lazyComponent._status = Rejected;lazyComponent._result = error;}},);// Handle synchronous thenables.switch (lazyComponent._status) {case Resolved:return lazyComponent._result;case Rejected:throw lazyComponent._result;}lazyComponent._result = thenable;throw thenable;}}
}
复制代码
转载于:https://juejin.im/post/5d11616d6fb9a07eae2a6a75
React 深度学习:ReactFiberLazyComponent相关推荐
- React 深度学习:ReactFiber
packages/react-reconciler/src/ReactFiber.js Fiber // A Fiber is work on a Component that needs to be ...
- React 深度学习:invariant
path: packages/shared/invariant.js 源码 /*** 根据条件抛出固定格式的错误,允许使用 %s 作为变量的占位符* * @param condition* @para ...
- 迁移学习,让深度学习不再困难……
2020-03-02 17:01:00 全文共2968字,预计学习时长9分钟 来源:Pexels 在不远的过去,数据科学团队需要一些东西来有效地利用深度学习: · 新颖的模型架构,很可能是内部设计的 ...
- “深度学习一点也不难!”
2020-02-14 11:11:15 通常情况下,机器学习尤其是深度学习的使用往往需要具备相当的有利条件,包括一个大型的数据集,设计有效的模型,而且还需要训练的方法--但现在,利用迁移学习就可以消除 ...
- 深度学习:在图像上找到手势_使用深度学习的人类情绪和手势检测器:第2部分
深度学习:在图像上找到手势 情感手势检测 (Emotion Gesture Detection) Hello everyone! Welcome back to the part-2 of human ...
- 机器学习 深度学习 ai_人工智能,机器学习,深度学习-特征和差异
机器学习 深度学习 ai Artificial Intelligence (AI) will and is currently taking over an important role in our ...
- 如何在TensorFlow中通过深度学习构建年龄和性别的多任务预测器
by Cole Murray 通过科尔·默里(Cole Murray) In my last tutorial, you learned about how to combine a convolut ...
- 深度学习去燥学习编码_通过编码学习编码
深度学习去燥学习编码 "Teach Yourself to program in 10 years." That's how Peter Norvig - a Berkeley p ...
- 媒智科技--深度学习算法Python后台开发--热招中~
点击我爱计算机视觉标星,更快获取CVML新技术 公司简介 媒智科技源起于上海交通大学,核心团队由上海交大.清华.斯坦福.乔治亚理工等顶尖高校的人工智能教授,以及来自雅虎.腾讯等科技精英组成,聚焦计算机 ...
最新文章
- jmeter 线程执行顺序_面试官让我说出8种线程顺序执行的方法!我懵了
- leetcode103JAVA_[LeetCode] 103. Binary Tree Zigzag Level Order Traversal Java
- Java中恒等条件判断:“equals”和“==”
- linux cache 内核参数,Linux内核中drop_caches参数
- RuoYi-Cloud 部署篇_02(linux环境 Oracle +nginx版本)
- 【codevs1285】【BZOJ1208】宠物收养所,splay练习
- UE3 内存使用和分析
- CEPH RGW集群和bucket的zone group 不一致导致的404异常解决 及 使用radosgw-admin metadata 命令设置bucket metadata 的方法
- python with open as yaml_python – pyyaml并仅使用字符串引号
- 若存在linux samba共享需关闭,Samba共享后不能访问是selinux惹的祸
- 游戏开发/游戏制作/游戏生成 , godot
- 计算机专业去,计算机专业去哪个学校_西信院
- fisher information 的直观意义
- 幂果支招:哪里找免费的Mac版音频剪辑软件
- 【python-docx】长度单位(毫米、厘米、英尺、磅等)的表示和转换关系
- 婚礼请柬邀请函电子版制作模板,520一起来参加婚礼吧!
- c语言求斐波那契数列n项以及前n项和
- haarcascades各种下xml下载
- Windows7优化开机速度的方法只需一步设置
- 为什么计算机处理打不开,为什么电脑ps安装成功打不开怎么办
热门文章
- spring的发展||springboot和微服务的介绍
- Spring Boot与数据访问
- 基本类型与字符串之间的转换
- servlet请求与响应的练习实例
- Linux下oracle数据库spfile参数配置文件丢失问题解决,“ORA-32001: write to SPFILE requested but no SPFILE is in use“问题处理
- python 技术篇-pythoncom.PumpMessag()关闭、杀死它的进程,pythoncom.PumpMessag()运行卡住解决办法
- esp8266 wifi信号强度设置
- 51单片机常用知识点总结
- CTFshow php特性 web89
- YTU_3137: 动态规划基础题目之拦截导弹