- React Cookbook
- Carlos Santana Roldan
- 144字
- 2021-07-16 17:49:41
Understanding React Pure Components
Many people get confused by the difference between a Functional Component and a Pure Component. Most of them think they are the same, but this is not true. When we use a Pure Component, we need to import PureComponent from React:
import React, { PureComponent } from 'react';
If your React component's render method is "pure" (that means it renders the same result, given the same props and state), you can use this function to improve the performance of your application. A Pure Component performs a shallow comparison for the props and nextProps objects as well as the state and nextState objects. Pure components do not include the shouldComponentUpdate(nextProps, nextState) method, and if we try to add it, we will get a warning from React.
In this recipe, we will create a basic example to understand how Pure Components works.
- Hands-On Industrial Internet of Things
- Web Application Development with R Using Shiny
- Learning Karaf Cellar
- 無人機通信
- 面向物聯網的嵌入式系統開發:基于CC2530和STM32微處理器
- 中小型局域網組建、管理與維護實戰
- Learning Swift(Second Edition)
- 智慧光網絡:關鍵技術、應用實踐和未來演進
- 網絡基礎與網絡管理項目化教程
- 通信原理及MATLAB/Simulink仿真
- Hands-On Microservices with Node.js
- 人際網絡
- 從物聯到萬聯:Node.js與樹莓派萬維物聯網構建實戰
- 中國信息化年鑒2017
- ReasonML Quick Start Guide