Mod 9 Flashcards

1
Q

If we want to execute some functionality when a React component is first mounted, which hook should we use?

A

useEffect

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can we run multiple Express servers, e.g., the one hosting a REST API and another hosting a development React app, on the same port on the same machine?

A

Hell no, you need different ports (ex: 3000 for Rest API and 8000 for React app)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a common technique to share state between different components that are not in an ancestor-descendant relationship?

A

Define the state to be shared in a common ancestor of the components and pass it down to the components that need to share it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the three stages in the lifecycle of a React component?

A

Mounting: initial Display

Updating: when setState() is called

Unmounting: When component is being removed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Consider the case when a page is first displayed and we want to display data in the page by calling a REST endpoint. When should we call the REST API and why?

A

We should call the REST API during the mounting stage since we want to display the data when the page is first displayed (this is when mounting occurs).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly