Context API
Review, Research, and Discussion
-
Describe use cases useState() vs useReducer()
useState()is setting the initial state and returning the actual state and a function to update the stateuseReducer()accepts a reducer function and an initial state, and it returns the actual state and a dispatch function. The dispatch function alters state in an implicit way by mapping actions to state transitions
-
Why do custom hooks need the use prefix?
- This convention is very important. Without it, React wouldn’t be able to automatically check for violations of rules of Hooks because React couldn’t tell if a certain function contains calls to Hooks inside of it.
-
What do custom hooks usually do?
- the custom hooks will keep functional components simple and clean
-
Using any list of custom hooks, research and name one that you think will be useful in your applications
- react-fetch-hook:it will get the data and the isLoading state
-
Describe how a hook that fetches API data might work
- by using useEffect() hook, we can get the API data when the component that contains API call function was updated
Document the following Vocabulary Terms
- reducer: a function that determines changes to an application’s state