Skip to content

Instantly share code, notes, and snippets.

@ferreiro
Last active July 22, 2018 01:57
Show Gist options
  • Save ferreiro/f0c846a00143b52c8b1a9b686a13b737 to your computer and use it in GitHub Desktop.
Save ferreiro/f0c846a00143b52c8b1a9b686a13b737 to your computer and use it in GitHub Desktop.

Answers to the questions from Lesson 2: Rendering UI with React

1) What is a component? How do components relate to props?

A component is a reactJS object that knows how to render itself and combines a bunch of small elements together with the goal of grouping and encapsulating functionality.

Props are one of the ways to pass data to a component. More in detail, props are the properties available to use for the component.

2) How do we know whether something should be a component in React?

We should use the same intuition as when designing classes in OOP languages: a component should represent an isolated idea/object in our App that groups together all the functionality required to meets the goal of the component.

As a general rule: we create components to represent ideas in of the business logic of the app and we achieve it’s goal by combining smaller elements through composition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment