State Flashcards

1
Q

What are hooks in React?

A

functions that let you “hook into” React state and lifecycle features from function components

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

What are the “Rules of Hooks”? (if necessary, re-read the “Pitfall” box in State)

A

Hooks—functions starting with use—can only be called at the top level of your components

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

What is the purpose of state in React?

A

o contain data or information about the component

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

Why can’t we just maintain state in a local variable?

A

it will only exist within that block if it is declared

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

What two actions happen when you call a state setter function?

A

it returns a function that it is using

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

When does the local state variable get updated with the new value?

A

when the action is done or when the state is used

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