Advanced State with Reducers
Review, Research, and Discussion
- How can we ensure that an effect hook runs only once?
- If you want to run an effect and clean it up only once (on mount and unmount), you can pass an empty array ([]) as a second argument.
- Can useState() update more than one state variable at the same time?
- No, but we can call useState more than once to update multiple variable.s
- Is useState() synchronous?
Vocab
- State Hook
- A Hook is a special function that lets you “hook into” React features.
- Component Lifecycle
- A component’s lifecycle is broadly classified into four parts:
- initialization
- mounting
- updating
- unmounting.