Not sure about what you're asking here, but this isn't a new discovery. There is an entire page on the official new React docs dedicated to teaching developers to rely on useEffect only as an "escape hatch" due to its tendency to be a code smell https://react.dev/learn/you-might-not-need-an-effect Also, last year's "Goodbye, useEffect: David Khourshid" conference talk basically outlined most of your discoveries, emphasizing to rely on events + callbacks over effects for cleaner code. Which unsurprisingly, many people took issue with (nobody likes hearing years of react code they've built is wrong) https://www.youtube.com/watch?v=HPoC-k7Rxwo So when should you use an Effect then? Treat is as a synchronization tool. Or more specifically, one you are forced to use to synchronize some piece of React code with some piece of external or third party system that does not offer an event-driven or "react-friendly" way of doing things. Answer from that_90s_guy on reddit.com
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › difference-between-usestate-and-useeffect-hook-in-reactjs
Difference Between useState and useEffect Hook in ReactJS - GeeksforGeeks
July 23, 2025 - Both useState and useEffect are ... in React. useState lets you manage and update the component state while useEffect allows you to handle side effects like the data fetching, DOM manipulation and cleanup....
🌐
Reddit
reddit.com › r/reactjs › thoughts on avoiding useeffect/usestate when possible in react?
r/reactjs on Reddit: Thoughts on avoiding useEffect/useState when possible in React?
November 7, 2023 -

obtainable fly bells wise terrific lunchroom light upbeat rhythm wild

This post was mass deleted and anonymized with Redact

Discussions

React: useEffect vs useMemo vs useState - javascript
I was trying to find a concise answer to this on the web without luck. Is the following correct regarding the differences between useEffect, useMemo and useState? Both useState and useMemo will re... More on stackoverflow.com
🌐 stackoverflow.com
Aren't useEffect and useState redundant?
They serve very different purposes. The only suggestion I can give you is to start over studying the what and why of both useState and useEffect. More on reddit.com
🌐 r/reactjs
24
0
January 31, 2022
Thoughts on avoiding useEffect/useState when possible in React?
Not sure about what you're asking here, but this isn't a new discovery. There is an entire page on the official new React docs dedicated to teaching developers to rely on useEffect only as an "escape hatch" due to its tendency to be a code smell https://react.dev/learn/you-might-not-need-an-effect Also, last year's "Goodbye, useEffect: David Khourshid" conference talk basically outlined most of your discoveries, emphasizing to rely on events + callbacks over effects for cleaner code. Which unsurprisingly, many people took issue with (nobody likes hearing years of react code they've built is wrong) https://www.youtube.com/watch?v=HPoC-k7Rxwo So when should you use an Effect then? Treat is as a synchronization tool. Or more specifically, one you are forced to use to synchronize some piece of React code with some piece of external or third party system that does not offer an event-driven or "react-friendly" way of doing things. More on reddit.com
🌐 r/reactjs
57
58
November 7, 2023
Can someone please explain the difference between useState and useReducer hook like I'm 5?
Their goal is the same: keeping state. With useState, you keep track of a single variable at a time: UseReducer allows for more complex state keeping, but you’ll have to write a function to merge new state with previously existing state yourself. The advantage is often you can dispatch “actions” on your state, the standard example being “increment” and “decrement”. So instead of updating state to state + 1, you can simply dispatch “increment”. Basically: as you write the implementation yourself, you have more freedom in how state is structured and how it’s updated based on existing state. More on reddit.com
🌐 r/reactjs
68
166
January 7, 2022
Top answer
1 of 3
83

To put it simply, both useState and useEffect enhance functional components to make them do things that classes can but functional components (without hooks) cannot:

  • useState allows functional components to have state, like this.state in class components.
  • useEffect allows functional components to have lifecycle methods (such as componentDidMount, componentDidUpdate and componentWillUnmount) in one single API.

Refer to the examples below for further illustration:

useState

class CounterClass extends React.Component {
  constructor(props) {
    super(props);
    this.state = { count: 1 };
  }
  
  render() {
    return <div>
      <p>Count: {this.state.count}</p>
      <button onClick={() => this.setState({ 
        count: this.state.count + 1
      })}>Increase</button>
    </div>;
  }
}

function CounterFunction() {
  const [count, setCount] = React.useState(1);
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => 
        setCount(count + 1)}
      >Increase</button>
    </div>
  );
}

ReactDOM.render(
  <div>
    <CounterClass />
    <CounterFunction />
  </div>
, document.querySelector('#app'));
<script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>

<div id="app"></div>

useEffect

class LifecycleClass extends React.Component {
  componentDidMount() {
    console.log('Mounted');
  }
  
  componentWillUnmount() {
    console.log('Will unmount');
  }
  
  render() {
    return <div>Lifecycle Class</div>;
  }
}

function LifecycleFunction() {
  React.useEffect(() => {
    console.log('Mounted');
    return () => {
      console.log('Will unmount');
    };
  }, []); // Empty array means to only run once on mount.
  return (
    <div>Lifecycle Function</div>
  );
}

ReactDOM.render(
  <div>
    <LifecycleClass />
    <LifecycleFunction />
  </div>
, document.querySelector('#app'));
<script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>

<div id="app"></div>

Read more about useState and useEffect on the official React docs.

2 of 3
29

For useState()

First, we have the functional component which did not supported state, in other words, a functional component is a stateless component.

Now, with Hooks, we have the functional component but stateful. It is achieved by using useState.


For useEffect()

First, with stateless functional component, we didn't have component lifecycle hooks. In other words, whenever you want to use component lifecycle hooks, you should consider using class component.

Now, we are able to use component lifecycle hooks without using class component. It is achieved by using useEffect. In other words, now whenever we want to use component lifecycle hooks, we already have two options either using class component or using Hooks with useEffect.


UPDATE

what’s the exact difference between useState and useEffect?

In simple words, useState allows our functional components which used to be stateless become stateful. And useEffect allows our functional components leverage the component lifecycle hooks which were, in the past, only supported for class components.

🌐
Medium
medium.com › @manojitdas180306 › understanding-the-differences-between-usestate-and-useeffect-in-react-5296ce78d574
Understanding the Differences Between useState and useEffect in React | by Manojit Das | Medium
July 9, 2024 - In summary, useState is ideal for managing state within your components, while useEffect is perfect for handling side effects that need to occur after rendering. By mastering these hooks, you can build more dynamic and responsive React applications.
🌐
SheCodes
shecodes.io › athena › 125174-difference-between-usestate-and-useeffect-in-react
[React] - Difference between useState and useEffect in | SheCodes
Learn about the difference between useState and useEffect hooks in React, and how they are used for state management and side effects.
Top answer
1 of 3
53

Your points are basically correct, some minor clarification:

useState is causing a re-render on the call of the setState method (second element in the array returned). It does not have any dependencies like useMemo or useEffect.

useMemo only recalculates a value if the elements in its dependency array change (if there are no dependencies - i.e. the array is empty, it will recalculate only once). If the array is left out, it will recalculate on every render. Calling the function does not cause a re-render. Also it runs during the render of the component and not before.

useEffect is called after each render, if elements in its dependency array have changed or the array is left out. If the array is empty, it will only be run once on the initial mount (and unmount if you return a cleanup function).

You can always check Hooks API Reference, which is a pretty solid documentation in my opinion

2 of 3
12
  • The return value of useEffect(callback, [dependency]) is void and It executes after render().
  • The return value of useMemo(callback, [dependency]) is NOT void but memoized value and It executes DURING render().

useEffect() can give same optimization as of useMemo() under the following circumstances:

  • The state variable used in the expensive computation (i.e., count1) is the only dependency of the useEffect.
  • When we don't mind storing the expensively computed value in state variable.
const [count1, setCount1] = useState(0);
const [expensiveValue, setExpensiveValue] = useState(null);
useEffect(() => {
    console.log("I am performing expensive computation");
    setExpensiveValue(((count1 * 1000) % 12.4) * 51000 - 4000);
  }, [count1]);   
  • Only difference is, useEffect() makes the expensively computed value available after render() while useMemo() makes the value available during the render().
  • Most of the time it does not matter because if that value has been calculated for rendering in the UI, useEffect() and useMemo() both will make the value available before browser finishes painting.
🌐
Codedamn
codedamn.com › news › react js
Mastering the Use of useState and useEffect Hooks in React.js
May 7, 2023 - A: useState is a hook used to manage state in functional components, while useEffect is a hook used to manage side effects (like fetching data, setting up event listeners, or updating the DOM) in functional components.
Find elsewhere
🌐
Syncfusion
syncfusion.com › blogs › react › understanding react’s useeffect and usestate hooks
Understanding React’s useEffect and useState Hooks | Syncfusion Blogs
November 6, 2025 - useState and useEffect are two of React’s most useful Hooks. This article serves as a guide to understanding and using them in appropriate places.
🌐
DEV Community
dev.to › enitschorn › react-s-useeffect-usestate-hooks-55fe
React's useEffect & useState hooks - DEV Community
May 12, 2021 - While I didn't find useState as complex as useEffect, there are some important characteristics to keep in mind when working with it: 1. Updating a state variable with the useState hook always replaces that variable instead of merging it (like setState does).
🌐
Codepath
guides.codepath.org › webdev › React-useEffect-vs-useState
React useEffect vs useState | CodePath Web Development Cliffnotes
The useState hook manages state—data that persists across renders and triggers re-renders when updated. It’s ideal for tracking component-specific data like user inputs or UI toggles. State refers to any data that is specific to a component and can change over time.
🌐
React
react.dev › reference › react › useEffect
useEffect – React
Call useEffect at the top level of your component to declare an Effect: import { useState, useEffect } from 'react'; import { createConnection } from './chat.js'; function ChatRoom({ roomId }) { const [serverUrl, setServerUrl] = useState('https://localhost:1234'); useEffect(() => { const connection = createConnection(serverUrl, roomId); connection.connect(); return () => { connection.disconnect(); }; }, [serverUrl, roomId]); // ...
🌐
W3Schools
w3schools.com › react › react_useeffect.asp
React useEffect Hooks
The useEffect Hook allows you to perform side effects in your components. Some examples of side effects are: fetching data, directly updating the DOM, and timers. useEffect accepts two arguments.
🌐
React
react.dev › learn › you-might-not-need-an-effect
You Might Not Need an Effect – React
const [fullName, setFullName] = useState(''); useEffect(() => { setFullName(firstName + ' ' + lastName); }, [firstName, lastName]); // ... } This is more complicated than necessary. It is inefficient too: it does an entire render pass with a stale value for fullName, then immediately re-renders with the updated value.
🌐
DEV Community
dev.to › rhythmsaha › the-difference-between-useeffect-and-usestate-a-simple-react-guide-5hdl
The Difference Between useEffect and useState: A Simple React Guide - DEV Community
August 4, 2025 - If you need a piece of data to change and cause a re-render *within* your component, you're looking for useState. It's for internal state. If you need to perform an operation *after* the component has rendered (or after certain data changes), ...
🌐
Initial Commit
initialcommit.com › blog › usestate-useeffect-hooks-react
A Guide to Using the useState and useEffect Hooks in React
February 23, 2022 - The useEffect hook allows components to react to lifecycle events such as mounting to the DOM, re-rendering, and unmounting. If you are learning React, you should make sure to learn these hooks well as they will prove to be extremely useful when developing React applications.
🌐
DEV Community
dev.to › wdp › best-practices-for-usestate-and-useeffect-in-react-4aea
Best Practices for useState and useEffect in React - DEV Community
January 18, 2024 - In React, useState and useEffect serve distinct purposes. useState is your go-to for tracking and reacting to changes within your component, ideal for direct state management and calculations based on state.
🌐
Stackademic
blog.stackademic.com › understanding-the-differences-between-usestate-and-useeffect-in-react-b61cad91df3c
Understanding the Differences Between useState and useEffect in React | by Olga Green | Stackademic
September 13, 2023 - Synchronous Updates: State updates with useState are synchronous, meaning the component re-renders immediately after a state change. On the other hand, useEffect is a hook that enables you to perform side effects in functional components.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-the-usestate-and-useeffect-hooks-in-your-project
React Hooks – How to Use the useState & useEffect Hooks in Your Project
October 8, 2024 - This is deemed appropriate because ... by the overarching logic within the component. The React useState Hook enables you to have state variables in functional components....
🌐
Medium
medium.com › @omkarbhavare2406 › react-is-a-cool-tool-for-building-dynamic-and-reusable-ui-stuff-aa3adab550e3
React Hooks: useState & useEffect | by Omkar Bhavare | Medium
December 13, 2023 - You can call useState multiple times in a single component to manage different pieces of state. useEffect is a React Hook that allows you to manage side effects within functional components.
🌐
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 ...