State Flashcards
(6 cards)
What are hooks in React?
functions that let you “hook into” React state and lifecycle features from function components
What are the “Rules of Hooks”? (if necessary, re-read the “Pitfall” box in State)
Hooks—functions starting with use—can only be called at the top level of your components
What is the purpose of state in React?
o contain data or information about the component
Why can’t we just maintain state in a local variable?
it will only exist within that block if it is declared
What two actions happen when you call a state setter function?
it returns a function that it is using
When does the local state variable get updated with the new value?
when the action is done or when the state is used