# State and Props

[Return to Home](https://sethppierce.github.io/reading-notes)

## Questions

### React Docs - lists and keys

What does .map() return?- a new array

If I want to loop through an array and display each value in JSX, how do I do that in React? map through the array and put the item within JSX tags

Each list item needs a unique ____.- Key

What is the purpose of a key?- Keys help React identify which items have changed, are added, or are removed.

### The Spread Operator

What is the spread operator?- an ellipsis of three dots (…) to expand an iterable object into the list of arguments.

List 4 things that the spread operator can do.- Copy an array, Combine Arrays, Add item to a list, Using an array as arguments.

Give an example of using the spread operator to combine two arrays. [...arr1, ...arr2]

Give an example of using the spread operator to add a new item to an array.- [...arr, item]

Give an example of using the spread operator to combine two objects into one.- {...obj1,...obj2}

### How to Pass Functions Between Components

In the video, what is the first step that the developer does to pass functions between components?- declares the function and passes it as a prop using the this. keyword

In your own words, what does the increment function do?- updates App.js's state and the correct person's count by 1

How can you pass a method from a parent component into a child component?- by using this.function and passing it as a prop inside the component

How does the child component invoke a method that was passed to it from a parent component?- by calling the this.props.function();
