/react-19:using-the-use-hookfrom react-19
React 19's use() API for reading Promises/Context conditionally. For async data fetching, Suspense, conditional context access, useContext migration.
Ships in react-19. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
use() Hook in React 19Teaches when and how to use React 19's new use() API: reads Promises (suspending component) and Context (conditionally—inside if statements, loops, after early returns).
Activates when: User mentions use(), use hook, async patterns, Suspense + data fetching, conditional context, or useContext migration.
| Feature | Hooks | use() |
|---|---|---|
| Conditional calls | ❌ | ✅ |
| After early return | ❌ | ✅ |
| Inside loops | ❌ | ✅ |
| Read Promises | ❌ | ✅ (suspends) |
| Error handling | try-catch | Error Boundary |
Reading Promises:
import { use, Suspense } from 'react';
async function fetchUser(id) {
const res = await fetch(`/api/users/${id}`);
return res.json();
}
function UserProfile({ userId }) {
return (
<Suspense fallback={<div>Loading...</div>}>
<UserData promise={fetchUser(userId)} />
</Suspense>
);
}
function UserData({ promise }) {
const user = use(promise);
return <div>{user.name}</div>;
}
Conditional Context Access:
import { use, createContext } from 'react';
const ThemeContext = createContext('light');
function Button({ isPrimary, children }) {
let className = 'button';
if (isPrimary) {
const theme = use(ThemeContext);
className += ` ${theme}`;
}
return <button className={className}>{children}</button>;
}
Reusable Custom Hook:
import { use, cache } from 'react';
const getUser = cache(async (id) => {
const res = await fetch(`/api/users/${id}`);
return res.json();
});
function useUser(userId) {
if (!userId) return null;
return use(getUser(userId));
}
Async data: Pass Promise as prop from parent → wrap component in Suspense boundary → use use(promise) in child → catch errors with Error Boundary.
Conditional context: Replace useContext(Context) with use(Context) for flexibility across conditional branches, loops, post-early-return.
Migration from useContext: Find useContext(Context) calls → replace with use(Context) → benefits: now conditional if needed.
MUST:
use(promise) in Suspense boundary with fallbackcache() wrapper to prevent duplicate requestsNEVER:
use() inside try-catch blocksuse() outside Component/Hook functionsVerify:
use(promise) with fallbackcache()—stable across rendersFor comprehensive React 19 use() documentation:
research/react-19-comprehensive.md lines 241–311 (use API, Promise Patterns, useContext sections).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub djankies/claude-configs --plugin react-1926 skills in this plugin
/composing-componentsTeaches component composition patterns in React 19 including children prop, compound components, and render props. Use when designing component APIs, creating reusable components, or avoiding prop drilling./following-the-rules-of-hooksFix React Rules of Hooks violations - conditional calls, hooks in loops/callbacks/classes/implementing-code-splittingTeaches code splitting with lazy() and Suspense in React 19 for reducing initial bundle size. Use when implementing lazy loading, route-based splitting, or optimizing performance.Other plugins' skills for the same job