As other answers have said, don’t avoid them - just use them with intention. This is a fantastic, official resource for knowing when to avoid using one: https://react.dev/learn/you-might-not-need-an-effect As the above dives into, it’s not just for performance. I’ve seen plenty of bugs and layout flickers that have resulted from incorrect uses of useEffect, particularly when state is changed inside the effect callback. Answer from santaschesthairs on reddit.com
🌐
React
react.dev › reference › react › useEffect
useEffect – React
See the difference between passing an array of dependencies, an empty array, and no dependencies at all. ... useEffect is a Hook, so you can only call it at the top level of your component or your own Hooks.
🌐
W3Schools
w3schools.com › react › react_useeffect.asp
React useEffect
React Compiler React Quiz React Exercises React Syllabus React Study Plan React Server React Interview Prep React Bootcamp React Certificate ... The useEffect Hook allows you to perform side effects in your components.
🌐
Reddit
reddit.com › r/reactjs › [noob] are useeffect hooks really that bad??
r/reactjs on Reddit: [Noob] are useEffect hooks really that bad??
February 10, 2025 -

am a junior full stack dev and my experience with react are limited to school projects. i've always use useEffect hooks and everything is great until i heard my senior devs complaining about the team using too many useEffect hooks in our codebase. things like our components get rendered unnecessarily and slowing down performance. ever since then, i'm very conscious about using useEffect.

so question is, are useEffect hooks really that bad and should i avoid using them at all cost? love to hear from yall cuz this is bothering me a lot and i want to be a better engineer

🌐
React
legacy.reactjs.org › docs › hooks-effect.html
Using the Effect Hook – React
By using this Hook, you tell React that your component needs to do something after render. React will remember the function you passed (we’ll refer to it as our “effect”), and call it later after performing the DOM updates.
🌐
Mimo
mimo.org › glossary › react › useeffect-hook
React useEffect Hook: Syntax, Usage, and Examples
The React useEffect hook lets you synchronize a component with external systems. It replaces lifecycle methods like componentDidMount, componentDidUpdate, and componentWillUnmount from class-based components.
🌐
PureCode AI
blogs.purecode.ai › home › how to master react useeffect to build great applications
How to Master React useEffect to Build Great Applications - Blogs
October 1, 2025 - Introduced in React 16.8, useEffect allows you to perform side effects in function components. Side effects could be data fetching, subscriptions, or manually changing the DOM, among others.
🌐
Dave Ceddia
daveceddia.com › useeffect-hook-examples
How the useEffect Hook Works (with Examples)
October 22, 2020 - The useEffect hook is the Swiss Army knife of all the hooks. It’s the solution to many problems: how to fetch data when a component mounts, how to run code when state changes or when a prop changes, how to set up timers or intervals, you name it. Pretty much anything you want to “do” in a React component other than return JSX (any sort of side effect), will go into a useEffect.
Find elsewhere
🌐
SitePoint
sitepoint.com › blog › javascript › understanding react useeffect
Understanding React useEffect — SitePoint
February 17, 2024 - The React useEffect hook is a powerful tool in the React developer’s arsenal. It allows you to perform side effects in your functional components, such as data fetching, subscriptions, or manually changing the DOM.
🌐
Effect
effect.website
Effect – The best way to build robust apps in TypeScript
Effect is a powerful TypeScript library designed to help developers easily create complex, synchronous, and asynchronous programs.
🌐
Next.js
nextjs.org › docs › messages › react-hydration-error
Text content does not match server-rendered HTML | Next.js
import { useState, useEffect } from 'react' export default function App() { const [isClient, setIsClient] = useState(false) useEffect(() => { setIsClient(true) }, []) return <h1>{isClient ?
🌐
useHooks
usehooks.com
useHooks – The React Hooks Library
A collection of modern, server-safe React hooks – from the ui.dev team
🌐
Overreacted
overreacted.io › a-complete-guide-to-useeffect
A Complete Guide to useEffect — overreacted
March 9, 2019 - There is no distinction between a “mount” or an “update” when rendering. You should think of effects in a similar way. useEffect lets you synchronize things outside of the React tree according to our props and state.
🌐
freeCodeCamp
freecodecamp.org › news › react-hooks-useeffect-usestate-and-usecontext
How to Use React Hooks – useEffect, useState, and useContext Code Examples
December 4, 2023 - The useEffect hook is used to perform side effects in your functional components, such as fetching data, subscribing to external events, or manually changing the DOM. It combines the functionality of componentDidMount, componentDidUpdate, and ...
🌐
Hygraph
hygraph.com › blog › react-useeffect-a-complete-guide
React useEffect() - A complete guide | Hygraph
January 21, 2026 - Class-based components and lifecycle methods are rarely used in modern React development. As mentioned, the useEffect Hook allows you to perform common side effects in function components.
🌐
X
x.com › alvinsng › status › 2035218502295200031
Alvin Sng on X: "Yup, we at @FactoryAI know this oh so well, which is why we’ve written about: - Banning useEffect() in React codebases - Using Linters to direct agents (I prefer calling it LDD: Lint Driven Development) - Agent Readiness (Fixing the codebase before letting agents roam wild) -" / X
@FactoryAI know this oh so well, which is why we’ve written about: - Banning useEffect() in React codebases - Using Linters to direct agents (I prefer calling it LDD: Lint Driven Development) - Agent Readiness (Fixing the codebase before letting agents roam wild) - Context compression, ensuring ...
🌐
Educative
educative.io › answers › what-is-the-useeffect-hook-in-react
What is the useEffect Hook in React?
A practical use case for useEffect is in a chatbox component to load previous messages and indicate the user’s activity when the component first mounts. Hooks were introduced in version 16.8 of React to enhance functional components, allowing them to manage state and other side effects traditionally handled in class components.
Top answer
1 of 2
14

I shall try to explain it in simple terms. useEffect is one of the most important hooks in react and is a way to handle life cycle of the component in which it is present.

useEffect runs on every render of the component (i.e when a state variable changes) and can also run every time a specific value changes that is mentioned in it's dependency array.

useEffect also provides a very useful cleanup function which can be used to remove any active listeners when the component changes

Here are a few examples:

  1. useEffect without dependency array
useEffect(() => {
    /*the code you want to run has to be in here which will keep running again and 
    again without stopping*/
})
  1. useEffect with empty dependency array
useEffect(() => {
    /*the code you want to run on every render has to be in here, the empty [] means 
    that the code will run every time this component mounts*/
},[])
  1. useEffect with state variables in dependency array
useEffect(() => {
    /*the code you want to run on every render has to be in here, the dependency
    array with state means that the code will run every time this component mounts as
    well as when these state variables change and the value will be captured by the
    useEffect*/
},[state1,state2])
  1. useEffect with state variables in dependency array and cleanup
useEffect(() => {
    /*the code you want to run on every render has to be in here, the dependency
    array with state means that the code will run every time this component mounts as
    well as when these state variables change and the value will be captured by the
    useEffect*/


    /*cleanup is used to remove any unwanted loops, intervals, listeners when the 
    component unmounts*/
    return () => console.log("clean up");
},[state1,state2])
  1. A complete example for useEffect from w3schools
import { useState, useEffect } from "react";
import ReactDOM from "react-dom/client";

function Timer() {
  const [count, setCount] = useState(0);

  useEffect(() => {
    let timer = setTimeout(() => {
    setCount((count) => count + 1);
  }, 1000);

  return () => clearTimeout(timer)
  }, []);

  return <h1>I've rendered {count} times!</h1>;
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Timer />);

If you still don't understand have a look at this

w3schools link for useEffect

react official documentation for useEffect

2 of 2
12

To understand useEffect, you have to understand React’s three lifestyle methods: Mounting, when the component is first render; Updating, when the component or state changes; and lastly, Unmounting.

useEffect as it says in the name defines a function (an effect) which will run at one of the three points. To differentiate between the three. You have a dependency array which defines when your effect will run.

For when the first page renders you would use an empty dependency array. For when a state changes you would use a dependency array which would look like this [state] and for when the component unmounts you would have an empty dependency array which would have a return statement in it which would run when it unmounts.

It would look like this:

useEffect(() => {}, [])

useEffect(() => {}, [state])

useEffect(() => {return () = {}}, [])

🌐
Epic React
epicreact.dev › myths-about-useeffect
Myths about useEffect | Epic React by Kent C. Dodds
July 9, 2024 - So, in our example, all we care about is: "When the dogId changes, fetch the new dog's information." With that as our goal, useEffect becomes much simpler for this case: ... 🤯 Oh snap. That's way better right?! When the React team introduced hooks, their goal wasn't to simply add lifecycles to function components.