DEV Community

Cover image for Top 7 React Hooks you must know

Top 7 React Hooks you must know

Vishnu Satheesh on February 22, 2025

React hooks have revolutionized the way we manage state and side effects in React functional components. With hooks, we can encapsulate reusable lo...
Collapse
 
ehsanpo profile image
Ehsan Pourhadi

useMemo and useCallback will be useless with react 19! :)

Collapse
 
gunslingor profile image
gunslingor

Really why? I mean, I always found them useless unless your dealing with a seriously flawed react application. I really build everything with just useState and useEffect, when those statements are a paragraph chunk of related gunk, I plop them in a custom hook with support functions near... once lifted appropriately. I tried reducers for some more complex data but honestly it hurts more than it helps 99% of the time, unless it's a global reducer in redux of course.

Anytime I do anything else with hooks in react, tends to cause issues, if nothing more than in coder comprehension and maintainability.

Only two hooks one should use imho, the rest aren't as good as a custom hook usually.

Collapse
 
cmacu profile image
Stasi Vladimirov

@gunslingor what you are describing is not react, but practically any other framework.
Reacts flawed reactivity model requires some form of memoization to prevent re-rendering, because it uses the component functions as units for state management. Compare that with Vue, or Solid, or Angular, or Svelte, where the main reactivity unit is a signal enabling modular rendering only affecting the part of the dom that was changed due to state changes.

Thread Thread
 
gunslingor profile image
gunslingor • Edited

Not sure I agree. What you are describing is a react app where state is not correctly under control, where things are rerendering when they should not, when no props have changed i suspect. When state lives in the level and component it should live in, rerendering happens when it should.

Components rerender when THEIR state changes (internal) so it should know better than anyone when it needs to rerender for this.

Components also rerender when their parent renders, and parents rerender when their state changes, or parent rerenders because their state changes... so their should be a state waterfall similar to DB relationality... when your DB is solid, your not using anything fancy.

Also Context changes, again though all stuff the dev has under control.

Thread Thread
 
gunslingor profile image
gunslingor

React is more opinionated than the frameworks you mention all of which ive used or tried over the years. React is component based to encourage controlled state, but its also extremely flexible so people often fail here and most react components I see in corporations are monstrosities... useMemo is a dead give away usually, because it's in a frankenstein function so no way it's being used as the vendor intended:

"You should only rely on useMemo as a performance optimization. If your code doesn’t work without it, find the underlying problem and fix it first. Then you may add useMemo to improve performance."

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
alireza0913088 profile image
Alireza Aslani

I understand all of these hooks.
Thanks for your post ☺️

Collapse
 
anemnavinrao profile image
Navin Rao ✍️

Useful hooks, thanks for sharing!

Collapse
 
designmonkey profile image
Peter Nielsen

Im surprised there is no more comments like this tbh. This article is just a "Hey ChatGPT - make an article about React" kind of article. I mean - what kind article about React start with about knowing useState? Like its literally the first thing you learn and not some hidden gem. It's just all the most common React hooks straight out of the documentation.

If this article should have any value it could have been 7 custom hooks that is good to know. But this is just trash and feels like somebody who just want to have a lot of articles on his name.

Collapse
 
vishnusatheesh profile image
Vishnu Satheesh

Thank you for your feedback. My goal with this post was to help beginners who are just stepping into the React world, which is why I covered the fundamental hooks first. And honestly, if even one person finds my blog helpful, that makes me really happy. 😊 Thanks again for your input!

Collapse
 
goodluck00112 profile image
Goodluck 👨‍💻

Amazing 💪

Collapse
 
reactoholic profile image
Petar Kolev

Such articles are such a noise and overflooding the internet...