DEV Community

Nurbek Aliqo'ziyev
Nurbek Aliqo'ziyev

Posted on

πŸš€ React 19 just changed the game: Goodbye useEffect, hello use()!

React 19 introduces use(), a powerful new hook that lets you:
βœ… Await promises directly inside your components
βœ… Skip useEffect, useState, and loading state logic
βœ… Let handle loading UI automatically
βœ… Throw errors directly β€” React catches them via Error Boundaries

πŸ”₯ Example:

import { use } from 'react';

const getUser = () => fetch('/api/user').then(res => res.json());

export default function UserComponent() {
  const user = use(getUser());
  return <p>Hello, {user.name}</p>;
}

Enter fullscreen mode Exit fullscreen mode
<Suspense fallback={<p>Loading...</p>}>
  <UserComponent />
</Suspense>

Enter fullscreen mode Exit fullscreen mode

🧠 Important: use() is mainly for data fetching (GET). For user interactions like forms, buttons, and POST requests, you’ll still use useState, onSubmit, etc.

*React is now more declarative, cleaner, and less error-prone than ever.
No more loading flags, boilerplate code, or side-effect spaghetti. Just readable, modern React. 🧼 *

Top comments (1)

Collapse
 
thunder6230 profile image
thunder6230

Usequery