Class-29 Readings: Routing
Class-29 Readings: Routing
Table of Contents
Reading, Research, and Discussion
1. Do child components have direct access to props/state from the parent?
- No, child components only have access to parent props/state when they are passed to them.
2. When a component “wraps” another component, how does the child component’s output get rendered?
- Rendering, is either rendered in place, or it is passed to the parent component to be called and used on the inside. I beleive the first option is best, I will need to test and determine this.
3. Can a component, such as <Content />, which is a child also be used as a standalone component elsewhere in the application?
- Yes, depend on how the component has been built or what its for, but yes, components are reusable.
4. What trick can a parent use to share all props with it’s children
- I believe a parent can pass props to the children as props, gaining access to all the props, but if they want state, a parent can pass a function so that a child can pass props, use state, and share information between parent and child.
Vocabulary Terms
props.children
:
- def: This method on props allows users to access nested children element within a component.
composition
:
- def: React, Composition is a natural pattern of the component model.
Additional Resources
Bookmark / Skim