-
Describe use cases useState() vs useReducer()
- use useReducer when you are using state that has multiple sub-values.
- useState is more useful when you have simple, singular state values
- source: reactjs.org
-
Why do custom hooks need the use prefix?
- it is a naming convention for react hooks
-
What do custom hooks usually do?
- handling, animation, timers, etc.
- source: reactjs.org
-
Using any list of custom hooks, research and name one that you think will be useful in your applications
- useToggle
- receives a boolean as parameter, generates the opposite action
- useful when you want to take the opposite action when the action is triggered by a true/false condition
- e.g. opening/closing a modal or menu
- source: usehooks.com
-
Describe how a hook that fetches API data might work
- it would use axios to query an api and store the response in state
reducer - a method that iterates through an array, operates on each value, ultimately producing a single value