If there are no other functions or expressions called when using the map function, what returns is a new array with values mapped to the original array.
If we want to loop through an array and display the value in react, we could embed it in a return in between curly brackets with an inline map() function.
Each item needs a unique key
The purpose of a key is to help react identify changes to an item (add, update, remove, etc.)
The spread operator
...
is a syntax used to add items to an array, combine array, objects, and to spread an array out into funtion arguments.
Add items to an array, combine arrays, combine objects, and spread an array into function arguments.
Give an example of using the spread operator to combine two arrays.
let array1 = [1, 2, 3];
let array2 = [3,4,5];
let combinedArray = ...[...array1,...array2];
// **OR** //
let combinedArray2 = [...array1,...array2];
Give an example of using the spread operator to add a new item to an array.
let originalArray = [0]
let array1 = [1, 2, 3];
let addedArray = [originalArray, ...array1];
Give an example of using the spread operator to combine two objects into one.
let object1 = {one: 1};
let object2 = {two:2};
let copiedArray = {...object1, ...object2};
Figure out what state we are trying ot change and Create the function whereever that is.
Passes in a specific personโs name, find the matching name in the array/object and update that specific one.
By passing it in as a props from the parent component to a child component.
by using the
this.props.methodName()