use() vs await: Why use() Works in Render
You'll learn why React's use() hook can read promises directly in render functions while await cannot.
The Fundamental Difference
In JavaScript, await can only exist inside async functions. Here's the problem: React component functions cannot be async. If you try async function MyComponent(), React won't know how to handle the returned Promise—it expects JSX, not a Promise that will eventually resolve to JSX.
This is where use() shines. It's designed specifically for React's rendering model. When you call use(promise), React doesn't wait synchronously. Instead, it:
- Suspends the component (throwing to the nearest Suspense boundary)
- Waits for the promise to resolve
- Re-renders the component with the resolved value
Think of it like this: await is a traffic stop sign—everything halts until the promise resolves. use() is more like a detour sign—React takes a different path (shows fallback UI), then comes back when ready.
Why This Matters
// ❌ This won't work - components can't be async
async function UserProfile({ userPromise }) {
const user = await userPromise; // Error!
return <div>{user.name}</div>;
}
// ✅ This works - use() integrates with Suspense
function UserProfile({ userPromise }) {
const user = use(userPromise); // Suspends, then re-renders
return <div>{user.name}</div>;
}
The magic is that use() works with React's concurrent rendering system. It can be called conditionally (unlike other hooks) because React tracks promise identity, not call order.
Key Takeaway: use() enables promise-reading in render functions by suspending components instead of blocking them, making it compatible with React's rendering model where async/await fundamentally cannot work.