Skip to the content.
Code 301 Class 03 Reading Notes
- What does .map() return? creates a new array populated with elements from the provided function on every element in the calling array.
- If I want to loop through an array and display each value in JSX, how do I do that in React? By transforming arrays into lists of elements, using
.map()
to loop through an array.
- Each list item needs a unique key or string.
- What is the purpose of a key? Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity.
- What is the spread operator? The spread operator is an ellipsis of three dots
(...)
to expand an iterable object into the list of arguments.
- List 4 things that the spread operator can do.
- Copying an Array
- Concatenating or combining arrays
- Using Math functions
- Using an array as arguments
- Give an example of using the spread operator to combine two arrays.
let merged = [...arr1, ...arr2];
- Give an example of using the spread operator to add a new item to an array.
let addMore = [1, 2, ...manyMore];
- Give an example of using the spread operator to combine two objects into one.
let totalObject = {...recallObj, ...recollectionObj};
- First step that the developer does to pass functions between components? Create a function where you will call and pass in a object with map.
- What does the
increment
function do? Looping through the people array, and checking if there is a match in the name, if there is a match, the count will increase by one.
- How can you pass a method from a parent component into a child component? Pass it with a prop, by creating something into the child component
- How does the child component invoke a method that was passed to it from a parent component? Call the parent method using props
Things I want to know more about
- How to Pass Functions between Components. Video was good, I think I just need more exposure to help with the specifics.
<—BACK