Course contentsShow
← React
Lesson 1472 of 2,39637. React 19 and BeyondFree lesson

What use() is: A Hook That Reads Promises and Context

Understanding use() as React's first hook that can consume promises directly in render, plus read context values.

What use() is: A Hook That Reads Promises and Context

You'll learn: What makes use() unique among React hooks and its two primary capabilities.

The First Hook That Breaks the Rules

Every React hook you've learned follows strict rules: call them at the top level, never conditionally, never in loops. use() is React's first hook that can be called conditionally — it's a revolutionary departure from traditional hook behavior.

Two Distinct Powers in One Hook

The use() hook serves two purposes:

1. Reading Promises Directly in Render

use() can unwrap promises during render, essentially letting you "wait" for async data without wrapping everything in Suspense boundaries manually. When you pass a promise to use(), React suspends the component until the promise resolves, then returns the resolved value.

Think of it like opening a gift box: you hand use() the wrapped promise, and it gives you the actual present inside.

2. Reading Context Values

use() can also read context, similar to useContext(), but with the flexibility to be called conditionally. This means you can read context only when certain conditions are met — something impossible with useContext().

Why This Matters

Before use(), consuming promises in render required complex patterns with Suspense boundaries and resource objects. Now you can handle async data more directly. The conditional calling ability also opens new compositional patterns that weren't possible with traditional hooks.

Example Shape (Not Runnable Yet)

// Reading a promise
const data = use(fetchPromise);

// Reading context conditionally
if (needsTheme) {
  const theme = use(ThemeContext);
}

Key Takeaway: use() is React's first conditionally-callable hook, uniquely designed to read both promises and context values, simplifying async patterns and enabling new compositional flexibility.