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
Framework: Adding withInstanceId Higher Order Component #1140
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would perhaps like to have seen tests and a README.md
, but otherwise can confirm this looks and works well 👍
Do we need another HOC, can’t we solve this with For the record, since c2732e7 visual editor block instances receive |
@nb We need a constructor to do so, which forces us to use the class component syntax and I'd much rather prefer the functional components unless we explicitly need refs, state or lifecycle methods. -- |
b31d859
to
171ee80
Compare
A class isn't so bad, so I’d still personally prefer less HOCs simply, because this way we need to communicate one less thing (what does this |
Another difference with the Thanks for the discussion, I'm merging now. This PR also bootstraps the Higher-Order Components Documentation. If the concern is raised again, we could revisit. |
I'm sympathetic to the "one less thing" argument, but higher-order components are a pretty fundamental pattern for shared component behaviors. In fact, I'd worry that shielding developers from the concept could be a disservice in, for example, understanding what something like |
We’re on the same page about |
Several components needs to generate an instanceId for HTML ids etc... In this PR I'm adding a
withInstanceId
Higher Order Component providing the instanceId as a prop.