render-props-pattern

Share rendering logic across React components using render props.

235|25|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/PatternsDev/skills --skill render-props-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: render-props-pattern
Source: https://github.com/PatternsDev/skills/tree/main/react/render-props-pattern
Command: npx skills add https://github.com/PatternsDev/skills --skill render-props-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reusable rendering logic across components by passing a function that returns JSX as a prop.

Core Features & Use Cases

  • Share UI rendering logic between components without creating tight coupling.
  • Enable flexible composition by delegating what gets rendered to child components.
  • Use case: render different headers for list items using the same data-fetching logic.

Quick Start

Create a simple component that takes a render prop and uses it to render a header for a list.

Frequently Asked Questions about render-props-pattern

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

FAQPage Schema
How do I share rendering logic between React components without tight coupling?

To share rendering logic between React components without tight coupling, pass a function that returns JSX as a prop. This delegates rendering to child components while keeping data-fetching or behavioral logic centralized.

What is a render prop in React and how does it work for component composition?

A render prop in React is a function prop that returns JSX, enabling flexible component composition. The parent component invokes this function to delegate what gets rendered, allowing child components to control the UI output.

When should I use render props instead of other component patterns in React?

Use render props in React when different parts of the UI require the same data or behavior but need to render different JSX. It is ideal for scenarios like rendering different headers for list items using the same data-fetching logic.

Can I use children as a function to achieve flexible rendering in React?

Yes, you can use children as a function to achieve flexible rendering in React. This common render prop variant accepts a function as the children prop, enabling flexible delegation of rendering while keeping code maintainable.

How do I create a React component that accepts a render prop?

To create a React component that accepts a render prop, define a component that takes a function prop and uses it to return JSX. This allows the component to pass data to the function, which then handles the UI rendering.

What are the limitations of using render props for code reuse in React?

The main limitation of render props for code reuse in React is potential prop drilling and callback hell. While it enables flexible composition, deeply nested render props can make the code harder to read and maintain.