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

Ref issue - interoperability with layers of HoCs #163

Closed
Andarist opened this issue Apr 5, 2017 · 5 comments
Closed

Ref issue - interoperability with layers of HoCs #163

Andarist opened this issue Apr 5, 2017 · 5 comments

Comments

@Andarist
Copy link
Collaborator

Andarist commented Apr 5, 2017

Aint sure if there is any established pattern how to do this.

Use case: accessing wrappedComponent's ref in each HoC wrapping it.

More here

Happy to send a PR if we can figure out how this should be tackled on library level.

@Pomax
Copy link
Owner

Pomax commented Apr 5, 2017

This is really something to discuss on the facebook react issue tracker instead - It would be amazing if some authority could formally declare that any HOC should offer two functions that return the class definition and the wrapped instance, so that all (or at least all the currently popular) HOC can be updated accordingly.

This one uses .getClass() and .getInstance() for that purpose (see https://github.com/Pomax/react-onclickoutside#but-how-can-i-access-my-component-it-has-an-api-that-i-rely-on) but if the React team can formally declare that one set of function names is to be the preferred method of guaranteeing HOC chaining works without effort, I will immediately update them to reflect that.

Can you file your suggestion on the react issue tracker? Keeping it on the eslint-plugin repo feels like it won't get the eyes on it that needs.

@Pomax
Copy link
Owner

Pomax commented Apr 5, 2017

As quick followup, refs rebinding is probably not good enough, as there is no rule that says you can only ever pass a single component into a HOC, and no rule that says HOCs may only use refs for contained components; as such, in order to make sure you can access "all" passed components you would need to do a blanket refs rebinding, but that will also expose references for bits that are internal to the HOC itself and should not be accessible for fiddling with.

If you start an issue on the react repo for this, let me know what the issue number is and I'll be happy to add as much information as I can.

@Andarist
Copy link
Collaborator Author

Andarist commented Apr 5, 2017

Yes, probably I'll write something up, just need to gather thoughts up.

@Pomax
Copy link
Owner

Pomax commented Apr 5, 2017

I've been thinking about this for a while myself, too, so I figured I might as well file facebook/react#9345 to get the ball rolling.

@Pomax
Copy link
Owner

Pomax commented Dec 8, 2017

I'm going to close this issue because this is not a thing we can solve "for everyone", and it's not an issue Facebook cared to solve with an authoritative API (as per the linked issue on their tracker)

@Pomax Pomax closed this as completed Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants