Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 1.37 KB

File metadata and controls

26 lines (21 loc) · 1.37 KB

Context API

Review, Research, and Discussion

  1. 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
  2. Why do custom hooks need the use prefix?

    • it is a naming convention for react hooks
  3. What do custom hooks usually do?

    • handling, animation, timers, etc.
    • source: reactjs.org
  4. 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
  5. Describe how a hook that fetches API data might work

    • it would use axios to query an api and store the response in state

Vocab Terms

reducer - a method that iterates through an array, operates on each value, ultimately producing a single value