React-08: state of the three core attributes of component instances

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

General shorthand for state

Guess you like

Origin blog.csdn.net/sinat_41696687/article/details/115049824
Recommended