Four answers to "how does a caller customize what a component renders?":
childrenand slot props. The caller passes elements:<Card>{content}</Card>, or named slots like<Layout header={<Header />} sidebar={<Nav />}>. The component only decides where they go. Since the caller created those elements, a re-render from the wrapper's own state skips them. react.dev suggests it, with plain props, before context. Limit: the wrapper can't pass its data into them.- Render props. A function prop the component calls with its data:
renderItem={(item, isActive) => <Row … />}, orchildrenas a function. Use it when the component owns data the caller's markup needs, such as which row is highlighted. Costs: a new function each render, and nesting when combined. - Compound components. A set of parts used together, like
<Tabs>,<Tab>and<Panel>. The parent provides shared state through context and each part reads it, so the caller controls structure and order. Prefer context overChildren.mappluscloneElement, which react.dev calls fragile: they see only the elements passed directly, not what a wrapper component renders. - Higher-order components.
withX(Component)returns a new component that renders the original with extra props. Problems: extra wrapper layers, prop-name collisions resolved silently, static methods not copied, and a HOC applied during render creating a new component type every time, which remounts and resets state. Refs used to needforwardRef; in React 19refis a prop, so spreading props forwards it.
HOCs aren't deprecated, but the legacy React docs say they "are not commonly used in modern React code". Hooks took over sharing logic. The Hooks FAQ: "Often, render props and higher-order components render only a single child. We think Hooks are a simpler way to serve this use case." Render props, slots and compound components remain the tools for structure.