Skip to content

Conversation

@menelike
Copy link
Contributor

@menelike menelike commented Feb 12, 2019

Pass ref to the wrapped component.

This might be a breaking change as:

  1. It requires at least React 16.3
  2. Refs targeting ReactMeteorDataComponent itself now don't work anymore (I thought of something like options.forwardRef for this, but in our large project we do not have even one case where we had to reference ReactMeteorDataComponent itself, so I skipped it)

fixes #202
fixes #189
fixes #162

@StorytellerCZ
Copy link
Collaborator

@hwillson Please take a look.

@holmrenser
Copy link

@dburles suggests adding this to a beta release in #262. Anything I can contribute to make this happen?

@menelike
Copy link
Contributor Author

@holmrenser thanks for your offer.

As far as I'm concerned, this PR is ready to be merged. I'd suggest to not wait for #262 to finish as there is still some work to do #262 (comment)

@holmrenser
Copy link

Cool! Since #262 is my main interest, I will try to help out there.

@menelike
Copy link
Contributor Author

@holmrenser #262 needs to catch up with the goal of this PR, maybe worth to be picked up by you?

@yched
Copy link
Contributor

yched commented Mar 30, 2019

So, #262 changes the withTracker() HOC to return a function component instead of a class component, so that it can leverage the new useTracker() hook introduced there, instead of soon-to-be-deprecated componentWillXxx() lifecycles at the moment.

Since function components can't receive refs, that would actually cause a BC break for existing code passing a ref to the HOC-wrapped component,. There are probably little actual use cases for doing that anyway, since as you point out above such refs currently reference the ReactMeteorDataComponent itself, but I do have one app that does just that (using the ref for ReactDOM.findDOMNode(), which works fine with the ref pointing to the ReactMeteorDataComponent - could/should be done differently now, since findDOMNode() will go away at some point, but point is, such code exists)

If this PR here gets merged and the official behavior becomes "withTracker forwards the ref to the decorated component", then this becomes a non-issue for #262, since React.forwardRef doesn't care about function vs. class components.

@dburles : how do you think we should move forward ?

@menelike
Copy link
Contributor Author

menelike commented Apr 2, 2019

@yched thanks a lot for your feedback, you've got a very valid point regarding breaking the backwards compatibility. Did not have that case in mind, thanks a lot!

Since #262 will result in a major release and breaks BC anyway, I'd vote for a solution where #262 supersedes this PR or a new PR targeting #262 like you proposed

I could include the forwardRef behavior in #262, but it's a behavior change that is probably better committed in a PR of its own.

Whatever we do, I think it makes a lot of sense to bundle the breaking changes from this PR and #262 into one release.

wdyt @yched ?

@menelike
Copy link
Contributor Author

menelike commented Apr 4, 2019

Superseded by eb55a16 from PR #262

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

Labels

None yet

Projects

None yet

4 participants