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>;
}
<Suspense fallback={<p>Loading...</p>}>
<UserComponent />
</Suspense>
π§ 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)
Usequery