View on GitHub

reading-notes

Review, Research, and Discussion

Describe use cases useState() vs useReducer() ?

useReducer is usually preferable to useState when you have complex state logic that involves multiple sub-values or when the next state depends on the previous one. useReducer also lets you optimize performance for components that trigger deep updates because you can pass dispatch down instead of callbacks.

Why do custom hooks need the use prefix?

Custom hooks are normal JS functions, named with the prefix ‘use’, that can use hooks inside of it and contain a common stateful logic to be reused in other components.

What do custom hooks usually do?

allow us to have cleaner functional components, remove logic from the UI layer, and prevent code duplication by bringing common use cases to reusable hooks.

Using any list of custom hooks, research and name one that you think will be useful in your applications

useOnClickOutside : This hook allows you to detect clicks outside of a specified element.

reducer

reducer is a function which takes two arguments — the current state and an action — and returns based on both arguments a new state.

Context


refrences :