react-state Flashcards

1
Q

What are hooks in React?

A

they allow you to use states in react

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

declared at the top, must have Use, no conditionals(must be called), only called in react component or another hook

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

Holds data between different renders/function calls

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

between functions local variables do not sync (when you call a function the variable will reset to the original state).

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

react will re-render and then updates the cache

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

after the render

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