Class 29
Resources:
Review, Research, and Discussion
- Do child components have direct access to props/state from the parent?
- Yes. When we need to pass data from a parent to child class component, you do this by using props.
- When a component “wraps” another component, how does the child component’s output get rendered?
- Child component’s output will get rendered when paraent component get rendered
- Can a component, such as
, which is a child also be used as a standalone component elsewhere in the application? - Yes. We can reuse components anywhere
- What trick can a parent use to share all props with it’s children
- we can spread the props attributes to pass it in JSX using the Spread operator
(three dots syntax (...))which passes the whole props object.
- we can spread the props attributes to pass it in JSX using the Spread operator
Vocabulary Terms
- Props.children
- It is a special prop, automatically passed to every component, that can be used to render the content included between the opening and closing tags when invoking a component. These kinds of components are identified by the official documentation as “boxes”.
- Composition
- It is a natural pattern of the component model. It’s how we build components from other components, of varying complexity and specialization through props. Depending on how generalized these components are, they can be used in building many other components.