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!
MIT License
3.65k stars 328 forks source link

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

Open Ross-Esmond opened 5 years ago

Ross-Esmond commented 5 years ago

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.

Ross-Esmond commented 5 years ago

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

tyroprogrammer commented 5 years ago

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!

Ross-Esmond commented 5 years ago

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.