reading-notes

Component Composition

Review, Research, and Discussion

Yes.

prop variables have a 100-character maximum limit.

From the parent compenent.

Document the following Vocabulary Terms

Preparation Materials

react basics recap

React’s props.children

props.children on components that represent ‘generic boxes’ and that ‘don’t know their children ahead of time’.

Example

const Picture = (props) => {
  return (
    <div>
      <img src={props.src}/>
      {props.children}
    </div>
  )
}

Composition vs Inheritance

Containment

Some components don’t know their children ahead of time. This is especially common for components like Sidebar or Dialog that represent generic “boxes”.

Specialization

Sometimes we think about components as being “special cases” of other components. For example, we might say that a WelcomeDialog is a special case of Dialog.

Inheritance

At Facebook, they use React in thousands of components, and they haven’t found any use cases where they would recommend creating component inheritance hierarchies.

Props and composition give you all the flexibility you need to customize a component’s look and behavior in an explicit and safe way. Remember that components may accept arbitrary props, including primitive values, React elements, or functions.