render-props-pattern

Implements the React render props pattern to share stateful logic between components.

1|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/TierOne-Studio/spa-velocity --skill render-props-pattern-tierone-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: render-props-pattern
Source: https://github.com/TierOne-Studio/spa-velocity/tree/main/.ruler/skills/render-props-pattern
Command: npx skills add https://github.com/TierOne-Studio/spa-velocity --skill render-props-pattern-tierone-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React components often need to share stateful logic with sibling or child components that have different rendering needs, and lifting state or using higher-order components can cause re-render issues, naming collisions, and implicit prop passing. ## Core Features & Use Cases - Render Prop Implementation: Pass a function as a render prop that receives component state and returns JSX, keeping rendering logic caller-controlled. - Children-as-a-Function Variant: Use the children prop as a function for a cleaner alternative to explicit render props. - Migration Guidance: Explains when to replace render props with custom Hooks to avoid deep component nesting, as seen in Apollo Client's evolution from Mutation/Query components to useQuery. - Use Case: Building a headless <DataLoader>{(state) => ...}</DataLoader> component that fetches data and lets each consumer decide how to render it. ## Quick Start Refactor this React component to expose its internal state through a render prop so callers control the rendered output.

Frequently Asked Questions about render-props-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use the render props pattern in React?

Pass a function as a `render` prop (or as `children`) that receives data and returns JSX. The component calls this function with its internal state, for example `props.render(value)`, letting the caller control what gets rendered.

Render props vs custom hooks in React: which should I use?

Custom hooks are preferred in most modern React code because they provide the same logic reuse without nested JSX. Use render props mainly for headless components where the caller must control rendering, or when a hook cannot express the API.

Render props vs higher-order components: what is the difference?

Render props pass data explicitly through function arguments, avoiding the naming collisions and implicit prop merging of HOCs. You can see exactly where each prop comes from in the render function's argument list.

Can I pass a function as children to a React component?

Yes, the `children` prop can be a function, which is technically a render prop. The component invokes `props.children(data)` with its state, and the caller writes `<Input>{(value) => ...}</Input>` to receive that data.

When should I avoid the render props pattern?

Avoid it when a custom hook achieves the same reuse with less ceremony, when it creates deeply nested JSX that hurts readability, or when the shared logic is simple enough for a plain utility function. Render props also cannot use lifecycle methods.