Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[examples] Replace HOC pattern with render-props pattern #2983

Closed
1 task done
mattbrunetti opened this issue Sep 25, 2017 · 1 comment
Closed
1 task done

[examples] Replace HOC pattern with render-props pattern #2983

mattbrunetti opened this issue Sep 25, 2017 · 1 comment

Comments

@mattbrunetti
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Context

I initially found the HOC pattern to be confusing, since (as a consumer) you can't explicitly see what prop(s) are being added.

(Also, it seems weird to create a component that can't stand on it's own, and then wrap it into something that can.)

Here is an explanation of the render-props pattern, which solves that (first) problem to offer a better Developer eXperience:

https://cdb.reacttraining.com/use-a-render-prop-50de598f11ce

@timneutkens
Copy link
Member

Major gotcha here is that the HOC in Next's case allows for implementing getInitialProps in the wrapping component. Whereas render props don't allow that.
Having said that I like render props very much, it just doesn't work in this case 😄

@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants