Context main usage scenarios

  • For the following components, props are used for communication between component A and component C or between component A and component D. For communication between component A and component B, props is used

Context usage steps (the following only applies to class components)

  1. Construct the Context container object (this object should be placed in an area that can be accessed by the parent’s children)

  2. Wrap it by calling the Provider property from the container object created in the first step (the value keyword below cannot be replaced by another keyword)

  3. The component that needs to receive is declared to receive

Common writing for functional and class components