Naming Conventions: render vs Named Props
You'll learn when to call your render prop render versus giving it a more descriptive name like renderItem or renderHeader.
The Naming Choice
When using the render props pattern, you have flexibility in what you call the prop that accepts a function. The most generic convention is simply naming it render:
<DataFetcher render={(data) => <div>{data}</div>} />
However, you can also give render props semantic names that describe what they're rendering:
<UserList renderItem={(user) => <li>{user.name}</li>} />
When to Use render
Use the generic render prop name when:
- Your component has only one render prop
- The component's primary purpose is to provide data or behavior without opinions about UI
- You're following a well-established pattern (like React Router's Route component used to)
When to Use Named Props
Use descriptive names like renderHeader, renderItem, or renderFooter when:
- Your component accepts multiple render props
- The name clarifies which part of the UI this function controls
- It improves readability and IDE autocomplete
<List
renderHeader={() => <h2>Users</h2>}
renderItem={(item) => <li>{item}</li>}
renderFooter={() => <button>Load More</button>}
/>
Think of it like function naming: render is like calling a function doThing(), while renderItem is like formatUserListItem() — more specific is often clearer.
Key Takeaway: Use render for single render props when the context is obvious; use descriptive names like renderItem or renderHeader when you have multiple render props or when clarity improves understanding.