React-08: state of the three core attributes of component instances
Others
2021-03-28 13:42:17
views: null
Accurately distinguish between simple components and complex components
- Simple component without state
- Complex components have state
Initialize state
- Modify in the constructor of the component class
- First pass the parameter props to the constructor, this parameter is automatically passed to us by React.
- Call super()
- Initialize state
- Here this refers to the instance object of the component
![](https://img-blog.csdnimg.cn/img_convert/8d2525c98893df8d6a26e3808e0f95e6.png)
General shorthand for state
![](https://img-blog.csdnimg.cn/img_convert/64ab1fa6810cb20b345deee225f224a5.png)
Origin blog.csdn.net/sinat_41696687/article/details/115049824