Effects Flashcards

1
Q

When is a component “mounted” to the DOM?

A

When the page is loaded after the page is loaded

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

What is a React Effect?

A

tell React that your component needs to do something after render

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

When should you use an Effect and when should you not use an Effect?

A

run something after a component that is already setup

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

When do Effects run?

A

Effects are always run after rendering

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

What function is used to declare an Effect?

A

useEffect()

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

What are Effect dependencies and how do you declare them?

A

(setup, dependencies) data or functions that can be passed has to be declared inside of the function

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

Why would you want to clean up from an Effect?

A

to keep the information from being scrambled, just incase something goes wrong

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

How do you clean up from an Effect?

A

return () =>
ignore true

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

When does the cleanup function run?

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