react-state Flashcards
What are hooks in React?
they allow you to use states in react
What are the “Rules of Hooks”? (if necessary, re-read the “Pitfall” box in State)
declared at the top, must have Use, no conditionals(must be called), only called in react component or another hook
What is the purpose of state in React?
Holds data between different renders/function calls
Why can’t we just maintain state in a local variable?
between functions local variables do not sync (when you call a function the variable will reset to the original state).
What two actions happen when you call a state setter function?
react will re-render and then updates the cache
When does the local state variable get updated with the new value?
after the render