/react-19:using-context-apifrom react-19
Teaches Context API patterns in React 19 including use() hook for conditional context access. Use when implementing Context, avoiding prop drilling, or managing global state.
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.
import { createContext, use, useState } from 'react';
const UserContext = createContext(null);
export function UserProvider({ children }) {
const [user, setUser] = useState(null);
return (
<UserContext value={{ user, setUser }}>
{children}
</UserContext>
);
}
export function useUser() {
const context = use(UserContext);
if (!context) {
throw new Error('useUser must be used within UserProvider');
}
return context;
}
use() allows context access inside conditionals (unlike useContext):
function Component({ isPremium }) {
let theme;
if (isPremium) {
theme = use(ThemeContext);
}
return <div className={theme}>Content</div>;
}
Avoid unnecessary re-renders by splitting contexts:
const UserContext = createContext(null);
const ThemeContext = createContext('light');
function App() {
const [user, setUser] = useState(null);
const [theme, setTheme] = useState('light');
return (
<UserContext value={{ user, setUser }}>
<ThemeContext value={{ theme, setTheme }}>
<Layout />
</ThemeContext>
</UserContext>
);
}
Now theme changes don't re-render components only using UserContext.
For comprehensive Context patterns, see: research/react-19-comprehensive.md lines 288-303, 1326-1342, 1644-1670.
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