当前位置:网站首页>Getderivedstatefromprops lifecycle
Getderivedstatefromprops lifecycle
2022-07-28 13:13:00 【Pig Xiaoyong】
The function of this life cycle is actually the incoming props Mapping to state above .
getDerivedStateFromProps It's a static function , That is, this function cannot pass this Access to the class Properties of , Direct access to properties is not recommended . It should be provided through parameters nextProps as well as prevState To judge , According to the new incoming props To map to state.
The function must have a return value . When props Incoming content does not need to affect state, You must return one null
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.id !== prevState.id) {
return {
editData: nextProps.editData,
id: nextProps.id,
targetKeys: nextProps.editData?.details?.map(item => item.companyId)
}
}
return null
}
边栏推荐
- Analysis of Andriod low on memory printing principle
- [FPGA] joint simulation of vivado and Modelsim
- [FPGA]: ISE generates MCS file and burning process
- Jetpack 全家桶之 LiveData 使用及源码篇
- 【嵌入式C基础】第9篇:C语言指针的基本用法
- [embedded C foundation] Part 6: super detailed explanation of common input and output functions
- Fundamentals of machine learning - principal component analysis pca-16
- [embedded C foundation] Part 1: basic data types
- A brief introduction to the for loop. Some of the code involves arrays
- How does kotlin help you avoid memory leaks?
猜你喜欢

Introduction to border border attribute

Comments are not allowed in JSON

【嵌入式C基础】第1篇:基本数据类型

How to improve deep learning performance?

Machine learning Basics - integrated learning-13

Chinese translation of pointnet:deep learning on point sets for 3D classification and segmentation

机器学习基础-集成学习-13

What if the win11 folder cannot be opened
![[graduation design teaching] ultrasonic ranging system based on single chip microcomputer - Internet of things embedded stm32](/img/27/58fd175753b21dc21bd2d950cf5f15.png)
[graduation design teaching] ultrasonic ranging system based on single chip microcomputer - Internet of things embedded stm32
![[matlab]: FFT related problems](/img/08/c721394c172bdfd1d5d55aef31ccbf.png)
[matlab]: FFT related problems
随机推荐
Databinding+LiveData轻松实现无重启换肤
Installation and reinstallation of win11 system graphic version tutorial
What if win11 cannot recognize Ethernet
RGB game atmosphere light touch chip-dlt8s04a-jericho
STM32 Development Notes - experience sharing
Qt 信号和槽机制( 详解 )
Huawei cloud Gao Hongxia: CBC microservice code Reconstruction & independent release practice
05 pyechars basic chart (example code + effect diagram)
Introduction to border border attribute
Stepless dimming colorful RGB mirror light touch chip-dlt8s12a-jericho
Machine learning practice - neural network-21
Machine learning Basics - decision tree-12
9、 Kubernetes configuration and storage
SSM框架网上书城全套
Solution to using json.tojsonstring to display question marks in Chinese in Servlet
Led aquarium lamp touch chip-dlt8t02s-jericho
[graduation design] smart home system based on ZigBee - single chip microcomputer Internet of things stm32
03 pyechars rectangular coordinate system chart (example code + effect drawing)
黑猫带你学eMMC协议第26篇:eMMC的硬件复位操作(H/W reset)
[embedded C foundation] Part 2: binary conversion and BCD coding