React PureComponent All In One
React PureComponent All In One
import React, {
// useState,
// useEffect,
// Component,
PureComponent,
} from "react";
// import "./style.css";
// pccs, PureComponent Class With Constructor
class App extends PureComponent {
constructor(props) {
super(props);
this.state = {};
}
render() {
const {
id,
name,
} = props;
return (
<>
<div>
<p>id = {id || 2020}</p>
<p>name = {name || xgqfrms}</p>
</div>
</>
);
}
}
export default App;
// pcs, PureComponent Class
class PCSApp extends PureComponent {
state = { }
render() {
return (
<>
<p>Hello, React Pure Component!</p>
</>
);
}
}
// export default PCSApp;
// pcsf, PureComponent Class FlowType
// type P = {
// str: string,
// };
// type S = {
// int: number,
// };
// class PCSFApp extends PureComponent<P, S> {
// state = { }
// render() {
// return (
// <>
// <p>pcsf, PureComponent Class FlowType</p>
// </>
// );
// }
// }
// export default PCSFApp;
PureComponent
https://reactjs.org/docs/react-api.html
UMD (CJS, global, AMD, CMD) + ESM
源码怎么实现的?

- ES6
React.Component
React.PureComponent
JSX, React.createElement() 语法糖
https://reactjs.org/docs/introducing-jsx.html
- ES5
create-react-class
https://reactjs.org/docs/react-without-es6.html
createElement()
createFactory()
https://reactjs.org/docs/react-without-jsx.html
Class Components vs Function Components (React Hooks)
https://reactjs.org/tutorial/tutorial.html
- Class Components
https://reactjs.org/docs/react-component.html
React.PureComponent 浅比较
https://reactjs.org/docs/react-component.html#shouldcomponentupdate
https://reactjs.org/docs/react-component.html#forceupdate
immutable objects 深比较
https://facebook.github.io/immutable-js/
React Lifecycle
很少使用到
shouldComponentUpdate(nextProps, nextState)
https://reactjs.org/docs/react-component.html#rarely-used-lifecycle-methods


refs
https://reactjs.org/docs/components-and-props.html
https://reactjs.org/docs/state-and-lifecycle.html
https://reactjs.org/docs/composition-vs-inheritance.html
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
React PureComponent All In One的更多相关文章
- React.Component 与 React.PureComponent(React之性能优化)
前言 先说说 shouldComponentUpdate 提起React.PureComponent,我们还要从一个生命周期函数 shouldComponentUpdate 说起,从函数名字我们就能看 ...
- [React] React.PureComponent
React.PureComponent is similar to React.Component. The difference between them is that React.Compone ...
- React.Component 和 React.PureComponent 、React.memo 的区别
一 结论 React.Component 是没有做任何渲染优化的,但凡调用this.setState 就会执行render的刷新操作. React.PureComponent 是继承自Componen ...
- [React] PureComponent in React
In this lesson, you will learn how to use PureComponent in React to reduce the number of times your ...
- 【react】---pureComponent的理解
一.pureComponent的理解 pureComponent表示一个纯组件,可以用来优化react程序.减少render函数渲染的次数.提高性能 pureComponent进行的是浅比较,也就是 ...
- React性能优化 PureComponent
为什么使用? React15.3中新加了一个 PureComponent 类,顾名思义, pure 是纯的意思, PureComponent 也就是纯组件,取代其前身 PureRenderMixin ...
- [React] Use React.memo with a Function Component to get PureComponent Behavior
A new Higher Order Component (HOC) was recently released in React v16.6.0 called React.memo. This be ...
- react 中的 PureComponent
React.PureComponent最重要的一个用处就是优化React应用,因为它减少了应用中的渲染次数,所以对性能的提升是非常可观的. 原理:在普通的 componnet 组件中,shouldCo ...
- React性能优化之PureComponent 和 memo使用分析
前言 关于react性能优化,在react 16这个版本,官方推出fiber,在框架层面优化了react性能上面的问题.由于这个太过于庞大,我们今天围绕子自组件更新策略,从两个及其微小的方面来谈rea ...
随机推荐
- 前端面试之ES6新增了数组中的的哪些方法?!
前端面试之ES6新增了数组中的的哪些方法?! 我们先来看看数组中以前有哪些常用的方法吧! 1 新增的方法! 1 forEach() 迭代遍历数组 回调函数中的三个参数 value: 数组中的每一个元素 ...
- 如何使用 Vuepress
项目结构 ├─docs │ ├─.vuepress --vuepress相关文件路径 (主要配置) │ │ ├─dist --build 打包生成路径 (自定义) │ │ ├─nav --导航条配置 ...
- Power of Two Choices 负载均衡
NGINX and the "Power of Two Choices" Load-Balancing Algorithm - NGINX https://www.nginx.co ...
- java面向对象(二)构造函数和构造代码块
面向对象 类成员 1.成员变量 属性 数值类型的基本数据类型默认值是 0 成员变量在任何方法中都能访问,和声明先后没有关系 2.成员函数 方法 3.定义方式 class 类名{成员变量:成员函数} / ...
- https://design-patterns.readthedocs.io/zh_CN/latest/index.html
图说设计模式 - Graphic Design Patterns https://design-patterns.readthedocs.io/zh_CN/latest/index.html
- Python学习【第7篇】:字符串拼接
1.格式化字符有%s,%d,%f浮点数 %s代表格式化字符串,s是string意思 msg = 'my name is %s'%"xiaoxing"print(msg)运行结果:m ...
- 我的刷题单(8/37)(dalao珂来享受切题的快感
P2324 [SCOI2005]骑士精神 CF724B Batch Sort CF460C Present CF482A Diverse Permutation CF425A Sereja and S ...
- Office系列---将Office文件(Word、PPT、Excel)转换为PDF文件,提取Office文件(Word、PPT)中的所有图片
将Office文件转换为PDF文件,提取Office文件中的所有图片 1.Office系列---将Office文件(Word.PPT.Excel)转换为PDF文件 1.1 基于Office实现的解决方 ...
- 关于项目中Spring版本与jdk1.8兼容问题解决
问题描述: 在用公司的工具搭建项目时,由于使用Spring框架,同时要求jdk版本为1.8:当部署完成以后,项目总是无法运行,会报错: Context namespace element 'annot ...
- httprunner(2)下载安装
环境要求 HttpRunner 是一个基于 Python 开发的测试框架,可以运行在 macOS.Linux.Windows 系统平台上.这里使用macOS系统进行演示 对于python版本要求:py ...