Remove the unnecessary use of render props in the component composition example. · Issue #7 · tyroprogrammer/learn-react-app · GitHub
Skip to content

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

Open

Description

@Ross-Esmond

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.

Activity

  1. Ross-Esmond commented on Feb 1, 2019

    @Ross-Esmond
    Author

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

  2. tyroprogrammer commented on Feb 2, 2019

    @tyroprogrammer
    Owner

    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!

  3. Ross-Esmond commented on Feb 2, 2019

    @Ross-Esmond
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions