Skip to main content
rule CX Codex

patterns-children-over-render-props — Claude Code rule: what it does

patterns-children-over-render-props — a Claude rule that pushes React components toward composition with children instead of renderX props, so call sites read as plain JSX.

MIT ★ 7,191 updated 2026-10-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/patterns-children-over-render-props.md
Open on GitHub

What patterns-children-over-render-props does

The file is a short style guide rated MEDIUM impact. It takes a form whose header, footer and action buttons arrive as callback props, then rebuilds the same thing from parts: a frame, a footer wrapper, plus input, formatting and emoji pieces slotted in as children.

One exception is written in. When the parent has data or state to hand down, render props stay: a List receiving data and renderItem is kept as the correct example. So the callbacks are not banned outright — the question is who owns the data.

Drop the file at .claude/rules/patterns-children-over-render-props.md. Without it in that path, Claude has no rule to load.

What it helps with

  • rewrite a form that takes renderHeader and renderFooter callbacks
  • split a monolithic component into Composer.Frame and Composer.Footer parts
  • judge whether a renderItem prop earns its place
  • strip callback props out of a component's public API
  • explain in review why children beat render functions

Example prompts for the agent

  • Rework Composer so the header and footer come in as children, not as renderHeader and renderFooter.
  • Split this form into Composer.Frame, Composer.Input and Composer.Footer.
  • Is renderItem the right call here, or should these be children?

How to install patterns-children-over-render-props

Manually: put the files in place

.claude/rules/patterns-children-over-render-props.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about patterns-children-over-render-props

How do I install patterns-children-over-render-props in Claude Code?

Add the rule file to your project at .claude/rules/patterns-children-over-render-props.md.

What does this rule do?

It tells the agent to build React components from children rather than renderX callbacks, keeping render props for the case where the parent supplies data or state.

When are render props the right choice?

When the child needs data or state from the parent. The rule's own example is a List that takes data and renderItem.

Source text

patterns-children-over-render-props.md · MIT
---
title: Prefer Composing Children Over Render Props
impact: MEDIUM
impactDescription: cleaner composition, better readability
tags: composition, children, render-props
---

## Prefer Children Over Render Props

Use `children` for composition instead of `renderX` props. Children are more
readable, compose naturally, and don't require understanding callback
signatures.

**Incorrect (render props):**

```tsx
function Composer({
  renderHeader,
  renderFooter,
  renderActions,
}: {
  renderHeader?: () => React.ReactNode
  renderFooter?: () => React.ReactNode
  renderActions?: () => React.ReactNode
}) {
  return (
    <form>
      {renderHeader?.()}
      <Input />
      {renderFooter ? renderFooter() : <DefaultFooter />}
      {renderActions?.()}
    </form>
  )
}

// Usage is awkward and inflexible
return (
  <Composer
    renderHeader={() => <CustomHeader />}
    renderFooter={() => (
      <>
        <Formatting />
        <Emojis />
      </>
    )}
    renderActions={() => <SubmitButton />}
  />
)
```

**Correct (compound components with children):**

```tsx
function ComposerFrame({ children }: { children: React.ReactNode }) {
  return <form>{children}</form>
}

function ComposerFooter({ children }: { children: React.ReactNode }) {
  return <footer className='flex'>{children}</footer>
}

// Usage is flexible
return (
  <Composer.Frame>
    <CustomHeader />
    <Composer.Input />
    <Composer.Footer>
      <Composer.Formatting />
      <Composer.Emojis />
      <SubmitButton />
    </Composer.Footer>
  </Composer.Frame>
)
```

**When render props are appropriate:**

```tsx
// Render props work well when you need to pass data back
<List
  data={items}
  renderItem={({ item, index }) => <Item item={item} index={index} />}
/>
```

Use render props when the parent needs to provide data or state to the child.
Use children when composing static structure.

© tech-leads-club · MIT · tech-leads-club/agent-skills

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set130

The whole set →
js-cache-storage js-cache-storage keeps localStorage, sessionStorage and cookie values in memory so reads stop hitting synchronous browser storage. CX Codex +1 ★ 7,191repo stars rerender-use-ref-transient-values The rerender-use-ref-transient-values rule teaches the agent to store frequently changing values in useRef instead of useState to avoid re-rendering the component on every update. CX Codex +1 ★ 7,191repo stars js-length-check-first js-length-check-first — a rule for Claude Code that prompts the AI to check array lengths before running expensive operations like sorting or deep equality checks. If lengths differ, arrays cannot be equal—no expensive work needed. CX Codex +1 ★ 7,191repo stars js-tosorted-immutable The js-tosorted-immutable rule replaces mutating .sort() with .toSorted(), keeping React props and state arrays unchanged during sorting. CX Codex +1 ★ 7,191repo stars js-cache-function-results js-cache-function-results instructs the agent to cache repeated function calls using a module-level Map. It eliminates redundant computations across renders and utility calls. CX Codex +1 ★ 7,191repo stars client-localstorage-schema The client-localstorage-schema rule guides Claude Code to version localStorage keys and keep only fields the UI needs. Use it when changing client-side settings or cached user data. CX Codex +1 ★ 7,191repo stars client-event-listeners client-event-listeners — a Claude rule that keeps a single keydown listener on window no matter how many components call the shortcut hook. CX Codex +1 ★ 7,191repo stars server-after-nonblocking server-after-nonblocking instructs the agent to schedule logging, analytics, and cleanup with Next.js after(). This sends responses right away without waiting for background work. CX Codex +1 ★ 7,191repo stars

Project sponsors

Companies that keep this analytics open