Skip to content
Agentmart
Submit a tool

react-composition-patterns

Patrones avanzados de composición en React y Next.js para componentes reutilizables y maintainables.

Skill by garri333

IndexedMIT★ 1
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/garri333-react-composition-patterns

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Patrones avanzados de composición en React y Next.js para componentes reutilizables y maintainables. Usa cuando diseñes arquitecturas de componentes, crees design systems, o refactorices componentes complejos.

Use cases: design, frontend

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/react-composition-patterns

What's inside

Skill name
react-composition-patterns
Description
Patrones avanzados de composición en React y Next.js para componentes reutilizables y maintainables. Usa cuando diseñes arquitecturas de componentes, crees design systems, o refactorices componentes complejos.
License
MIT
Instructions
354 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Files (1)

  • SKILL.md

SKILL.md (first lines)

# React Composition Patterns

## Cuándo usar esta skill
- Diseñar la arquitectura de un sistema de componentes
- Refactorizar un componente que se está volviendo muy complejo
- Crear componentes flexibles y reutilizables
- Código revisión sobre estructura de componentes React

## Patrones principales

### 1. Compound Components
Componentes que trabajan juntos, compartiendo estado implícitamente.

```tsx
// ✅ Compound Component pattern
interface TabsContextType {
  activeTab: string;
  setActiveTab: (tab: string) => void;
}

const TabsContext = createContext<TabsContextType | null>(null);

function useTabsContext() {
  const ctx = useContext(TabsContext);
  if (!ctx) throw new Error("useTabsContext must be used within Tabs");
  return ctx;
}

function Tabs({ children, defaultTab }: { children: React.ReactNode; defaultTab: string }) {
  const [activeTab, setActiveTab] = useState(defaultTab);
  return (
    <TabsContext.Provider value={{ activeTab, setActiveTab }}>
      <div className="tabs">{children}</div>
    </TabsContext.Provider>
  );
}

Tabs.List = function TabList({ children }: { children: React.ReactNode }) {
  return <div role="tablist" className="tabs-list">{children}</div>;
};

Tabs.Tab = function Tab({ id, children }: { id: string; children: React.ReactNode }) {
  const { activeTab, setActiveTab } = useTabsContext();
  return (
    <button
      role="tab"
      aria-selected={activeTab === id}
      onClick={() => setActiveTab(id)}
    >
      {children}
    </button>
  );
};

Tabs.Panel = function TabPanel({ id, children }: { id: string; children: React.ReactNode }) {
  const { activeTab } = useTabsContext();
  if (activeTab !== id) return null;
  return <div role="tabpanel">{children}</div>;
};

// Uso:
<Tabs defaultTab="tab1">
  <Tabs.List>
    <Tabs.Tab id="tab1">Tab 1</Tabs.Tab>
    <Tabs.Tab id="tab2">Tab 2</Tabs.Tab>
  </Tabs.List>
  <Tabs.Panel id="tab1">Contenido 1</Tabs.Panel>
  <Tabs.Panel id="tab2">Contenido 2</Tabs.Panel>
</Tabs>
```

### 2. Render Props
Pasa lógica como prop para máxima flexibilidad de renderizado.

```tsx
// ✅ Render Props
interface DataFetcherProps<T> {
  url: string;
  render: (data: T | null, loading: boolean, error: Error | null) => React.ReactNode;
}

function DataFetcher<T>({ url, render }: DataFetcherProps<T>) {
  const [data, setData] = useState<T | null>(null);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState<Error | null>(null);

  useEffect(() => {
    fetch(url)
      .then(r => r.json())
      .then(setData)
      .catch(setError)
      .finally(() => setLoading(false));
  }, [url]);

  return render(data, loading, error);
}

// Uso:
<DataFetcher<User>
  url="/api/user"
  render={(user, loading, error) => {
    if (loading) return <Spinner />;
    if (error) return <ErrorMessage error={error} />;
    return <UserCard user={user!} />;
  }}
/>
```

### 3. Higher Order Components (HOC)
Envuelve un componente para añadir funcionalidad.

```tsx
// ✅ HOC para autenticación
function withAuth<P extends object>(
  WrappedComponent: React.ComponentType<P>,
  redirectTo = '/login'
) {
  return function AuthenticatedComponent(props: P) {
    const { user, loading } = useAuth();

From garri333/Skills, MIT.

More from garri333/Skills

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
Feb 18, 2026 (8 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from garri333

Cite this page

react-composition-patterns skill. Agent Mart. https://agentmart.dev/skills/garri333-react-composition-patterns (last updated 2026-10-24)