render-props-pattern

Compose React components by passing render functions as props.

1|Updated Jul 12, 2025
One-click install
npx skills add https://github.com/ubay1/next15-starter --skill render-props-pattern-ubay1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: render-props-pattern
Source: https://github.com/ubay1/next15-starter/tree/main/.agents/skills/render-props-pattern
Command: npx skills add https://github.com/ubay1/next15-starter --skill render-props-pattern-ubay1

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The render props pattern solves the problem of sharing stateful logic across components when rendering needs vary, without relying on prop injection patterns that can get messy.

Core Features & Use Cases

  • Reusable composition with a render prop: Pass a function as a prop (commonly render) that returns JSX so the parent supplies data and the child controls rendering.
  • Children-as-a-function alternative: Use props.children as the render function to reduce naming friction and improve readability.
  • Use case: A temperature input where the input manages the typed Celsius value, while sibling renderers (e.g., Fahrenheit and Kelvin) render different views based on that shared value.

Quick Start

Ask the AI to show how to refactor your stateful component to accept a render (or function-as-children) prop that receives data and returns the JSX for multiple consumer components.

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 React component state across multiple child renderers with custom JSX?

The render props pattern solves this by having a parent component pass a function as a prop. This function receives the parent's computed stateful data as arguments and returns custom JSX, allowing multiple child components to render different views based on that shared state.

What is the children as a function pattern in React?

The children as a function pattern is an alternative render props approach where you pass a function as the `props.children` prop instead of using a named `render` prop. This reduces naming friction and improves readability while still sharing stateful data with flexible rendering.

How do I refactor a stateful React component to use a render prop?

Refactor your stateful React component to accept a `render` prop, then invoke that provided render function with the component’s computed data. The function will return the necessary JSX elements, allowing the parent to supply data while the child controls the rendering output.

When should I use render props instead of React Hooks for component composition?

You should use render props when multiple child renderers need custom JSX output based on shared state, though React Hooks are generally preferred when possible. Render props fit scenarios where a component manages data retrieval while sibling components need flexible rendering.