-
.map
returns an array with the same length as the input array. -
const outputElements = inputArray.map((value) => <outputValue />)
-
Each list item needs a unique key.
-
Keys help React identify which items have changed, are added, or are removed. — reactjs.org
-
“When ...arr is used in the function call, it ‘expands’ an iterable object arr into the list of arguments.” — JavaScript.info
-
The spread operator can be used to
-
Copy an array
-
Use the items in an array as arguments
-
Concatenate arrays
-
Combine objects
-
-
const newArray = [...[arrayOne], ...[arrayTwo]]
-
const newArray = [newItem, ...[array]]
-
const newObject = {...{obectOne}, ...{objectTwo}}
-
The first step is creating the function inside the parent component.
-
It loops through the people array to find the right name and increments that person's count by one.
-
A method can be passed as a prop from a parent to child component.
-
Call a parent method by using
this.props.functionName
.