Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Home Community What is the difference between useState and useEffect in Re…

What is the difference between useState and useEffect in React?

Coding Now Expert  •  Jun 13, 2026  •  252 views
**useState** — manages state (data that can change over time)
**useEffect** — handles side effects (API calls, subscriptions, timers)

```jsx
import { useState, useEffect } from 'react';

function Profile({ userId }) {
const [user, setUser] = useState(null); // useState

useEffect(() => { // useEffect
fetch(`/api/users/`)
.then(r => r.json())
.then(setUser);
}, [userId]); // runs when userId changes

if (!user) return <p>Loading...</p>;
return <h1>{user.name}</h1>;
}
```
0

0 Answers

Your Answer

Will not be displayed publicly
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →