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
.claude/rules/patterns-children-over-render-props.mdWhat 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
renderHeaderandrenderFootercallbacks - split a monolithic component into
Composer.FrameandComposer.Footerparts - judge whether a
renderItemprop 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
Composerso the header and footer come in aschildren, not asrenderHeaderandrenderFooter. - Split this form into
Composer.Frame,Composer.InputandComposer.Footer. - Is
renderItemthe 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.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/patterns-children-over-render-props.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/patterns-children-over-render-props.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/patterns-children-over-render-props.mdManually: put the files in place
.clinerules/patterns-children-over-render-props.mdStep 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