React hook are special functions that let you “hook into” react features like state and life-cycle methods in functional components . before hooks , these features were only available in class components . hooks make it easier to write and manage it easier to write
and manage react code.
useState()
The useState is a react hook which help manage state of variables and we can update the state of that variable as well .
useEffect()
the useEffect refresh the web page after every change in web page . it mostly use in event handling whenever there is an update in a web page so that it can display the changes after an event.
useContext()
It is use to create a context so that we can access all the variables and functions across the component tree and aviod props driling. lets you access data from react context.
useReducer()
Manages complex state logic using a reducer function . A function that takes the current state and an action, and returned a new state. a more advanced way to manage state , especially for complex logic.
useCallback()
Memorizes a callback function to prevent unnecessary re-renders . Usefull when passing callbacks to child components to optimize performance
useMemo()
Memorize a value to avoid expensive calculations on every render.
useRef()
Create a mutable object that persists across renders.
1 Comment
One thing I’ve noticed is that hooks like `useEffect` can sometimes cause unnecessary rerenders if not carefully handled. It would be great to see a deeper dive into performance optimizations when using hooks.