Code Fellows Notes
A component should ideally only do one thing. If it ends up growing, it should be decomposed into smaller subcomponents.
To build a version that takes your data model and renders the UI but has no interactivity. To build a static version of your app that renders your data model, you’ll want to build components that reuse other components and pass data using props.
The interactive features: via state.
Think of the minimal set of mutable state that your app needs. The key here is DRY: Don’t Repeat Yourself. Figure out the absolute minimal representation of the state your application needs and compute everything else you need on-demand.
Identify every component that renders something based on that state.
Find a common owner component (a single component above all the components that need the state in the hierarchy).
Either the common owner or another component higher up in the hierarchy should own the state.
If you can’t find a component where it makes sense to own the state, create a new component solely for holding the state and add it somewhere in the hierarchy above the common owner component.
A function that operates on other functions, either by taking them as arguments or by returning them
It returns the value of an arrow function that takes a variable and compares its value against another variable to determine whether or not the first value is greater than the second value.
Thus this is a higher-order function creating another function that is performing that task.
map()
is a higher-order function that applies a given function to each element of a collection (e.g. a list in an array) returning the results in a collection of the same type.
reduce()
is a very useful Higher-Order Function built into JavaScript. It summarizes the total of an array. It will compute a single value from a collection of numbers in an array and return that number: the total.