reading-notes

Reading Journal

This topic is important because passing functions between components is essential to enable communication and data flow between parent and child components. The spread operator is useful for efficiently altering and merging arrays or objects, it also provides a clear syntax for these tasks. Keys are crucial in efficiently rendering and updating components within lists, optimizing performance and maintaining a stable user experience.

Reading

React Docs - lists and keys

1. What does .map() return?

2. If I want to loop through an array and display each value in JSX, how do I do that in React?

3. Each list item needs a unique ___.

4. What is the purpose of a key?

The Spread Operator

1. What is the spread operator?

2. List 4 things that the spread operator can do.

3. Give an example of using the spread operator to combine two arrays.

const arrayOne = [1, 3, 5]; const arrayTwo = [2, 4, 6];

const combineArray = [...arrayOne, ...arrayTwo];

4. Give an example of using the spread operator to add a new item to an array.

const ogArray = [1, 3, 5]; const newArray = [...ogArray, 7];

5. Give an example of using the spread operator to combine two objects into one.

const person = {name: 'John', age: 25, gender: 'male' }; const addInfo = {age: 26, city: 'New York' };

const updatedPerson = {...person, ...addInfo };

Videos

How to Pass Functions Between Components

1. In the video, what is the first step that the developer does to pass functions between components?

2. In your own words, what does the handleClick function do?

3. How can you pass a method from a parent component into a child component?

4. How does the child component invoke a method that was passed to it from a parent component?

Things I want to know more about.

I would like to research, at a greater depth, React component lifecycles to better understand the concept.