Skip to content

Latest commit

 

History

History
47 lines (24 loc) · 2.1 KB

301Read05.md

File metadata and controls

47 lines (24 loc) · 2.1 KB

Reading 5 - Putting it all together

Source: React Docs

Q1 What is the single responsibility principle and how does it apply to components?

The single responsibility principle, when applied to components, means that a component should only do one thing.

Q2 What does it mean to build a ‘static’ version of your application?

A static version just renders the UI without any interactivity. They have componenets that reuse other components and pass data via props.

Q3 Once you have a static application, what do you need to add?

State

Q4 What are the three questions you can ask to determine if something is state?

Something is state if it:

  1. Changes over time

  2. Isn't passed in from a parent via props

  3. Can't be computed based on existing state or props

Q5 How can you identify where state needs to live?

Identify all of the componenets that render something based on that state, and find their closest common parent component.

Source: Eloquent JavaScript

Q6 What is a “higher-order function”?

A higher-order function is a function that operates on another function, either by taking them as arguments or returning them.

Q7 Explore the greaterThan function as defined in the reading. In your own words, what is line 2 of this function doing?

The second line of the function returns a new function. That new function takes the original value, n, and compares it to the new value, m, passed into the new function. It will return true if m > n.

Q8 Explain how either map or reduce operates, with regards to higher-order functions.

'Map' is a higher order function that takes in both an array and a callback function as arguements. It returns a new array, that is the same length as the original array, that is populated by the result of applying the callback function on each element of the array.

Things I want to know more about

How to break up a mockup into components. I followed along with the example, but I feel like I would quickly get confused trying to do it myself.