render-props-pattern

Implements the render props pattern for sharing rendering logic between React components.

1|Updated Jul 4, 2026
One-click install
npx skills add https://github.com/trungenglish/SHOPWISE --skill render-props-pattern-trungenglish
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: render-props-pattern
Source: https://github.com/trungenglish/SHOPWISE/tree/main/.agents/skills/render-props-pattern
Command: npx skills add https://github.com/trungenglish/SHOPWISE --skill render-props-pattern-trungenglish

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React components often need to share stateful logic while rendering different UI, and lifting state or using higher-order components can cause prop collisions, deep nesting, or unnecessary re-renders. This Skill teaches how to apply the render props pattern to decouple stateful logic from presentation. ## Core Features & Use Cases - Render Prop Implementation: Pass a function as a render prop that receives component data and returns JSX. - Children-as-a-Function: Use the children prop as a function for a cleaner alternative to explicit render props. - Migration Guidance: Learn when to replace render props with custom Hooks to avoid deep component nesting. - Use Case: Build a temperature converter where a stateful Input component shares its value with Kelvin and Fahrenheit display components via a render prop, without lifting state to a common ancestor. ## Quick Start Show me how to refactor my React component to share its state with child components using the render props pattern.

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 prop (commonly named `render`) that receives data and returns JSX. The component calls this function with its internal state, like `props.render(data)`, letting the parent control rendering while the component owns the logic.

What is the children-as-a-function pattern in React?▼

Children-as-a-function passes a function as the `children` prop instead of JSX. The component invokes `props.children(data)` with its state, giving child content access to that data without naming an explicit render prop.

Render props vs higher-order components: which should I use?▼

Render props avoid the naming collisions and implicit prop merging that HOCs introduce, since props are passed explicitly through the function's arguments. Render props also make data sources visible in the arguments list, improving traceability.

When should I replace render props with React Hooks?▼

Replace render props with custom Hooks when nesting multiple render prop components creates hard-to-read JSX. Hooks provide the same logic reuse without wrapper components, as demonstrated by Apollo Client's move from Mutation/Query components to useQuery.

What are the limitations of the render props pattern?▼

Render props cannot use lifecycle methods, so they only suit components that do not need to alter received data. Deeply nested render props also harm readability, and most reuse cases are now better served by custom Hooks.