tyroprogrammer / learn-react-app

Application that will help you learn React fundamentals. Install this application locally - there's tutorial, code snippets and exercises. The main objective of this project is to help you get off the ground with React!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove the unnecessary use of render props in the component composition example.

Ross-Esmond opened this issue · comments

The use of render props is misguided in the Card example. Render props allow a parent component to provide data to a render without having to explicitly know what its children are. If a render prop takes no arguments it should just be swapped out for static JSX.

To be clear, I'm referring to the use of arrow functions to wrap the jsx. Not the passing of children into properties.

I agree that in this case arrow function is not really doing anything but the goal really was to show that you can pass function as props that will return what to render. Maybe instead of getting rid of the arrow function it's better to change the exercise slightly so that the caller is passing some data to the render props!

Yep, and that makes since. Although I would still suggest removing the functions in favor of a simpler, more direct approach. Most of your tutorial focuses on building an understanding of the fundamentals. Which is good, because that's actually where most people struggle. I just wouldn't want someone to conflate composition with render props specifically. Composition through children passing is a strong enough tool to get a dedicated section.