React Docs - Thinking in React
There are two types of “model” data in React: props and state. props (short for “properties”) and state are both plain JavaScript objects. While both hold information that influences the output of render, they are different in one important way: props get passed to the component (similar to function parameters) whereas state is managed within the component (similar to variables declared within a function).
- What is the single responsibility principle and how does it apply to components?
The single-responsibility principle (SRP) is a computer-programming principle that states that every module,
class or function in a computer program should have responsibility over a single part of that program's functionality,
and it should encapsulate that part.
React Componemt is a single functionality that used to constitute the whole app.
- What does it mean to build a ‘static’ version of your application?
A Static Web Application is any web application that can be delivered directly to
an end user's browser without any server-side alteration of the HTML, CSS, or JavaScript content.
- Once you have a static application, what do you need to add?
Add state to make your UI interactive.
- What are the three questions you can ask to determine if something is state?
Is it passed in from a parent via props? If so, it probably isn’t state.
Does it remain unchanged over time? If so, it probably isn’t state.
Can you compute it based on any other state or props in your component? If so, it isn’t state.
- How can you identify where state needs to live?
which conponent mutates, or status changes over time.
Higher-Order Functions
- What is a “higher-order function”?
Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions.
- Explore the greaterThan function as defined in the reading. In your own words, what is line 2 of this function doing?
return m if m grater than n
- Explain how either map or reduce operates, with regards to higher-order functions.
The map method transforms an array by applying a function to all of its elements and building a new array from the returned values.