API: Add 'ref' for primitives for direct access to Node #139
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change proposes adding a
ref
to the primitive nodes, that gives access to the underlying node. This isn't meant to be a common scenario by any means, but there are a few reasons I think we need this:<Slider />
, we need to know the calculated layout values (the width/height) of the component. We can get that directly via thenode
, but perhaps a better event would be useful for that down the road - likeonLayoutChanged
?<Clickable />
, we really want to capture the mouse input at the start of themousedown
gesture, and then, when it is released, check if themouseup
occurred in the bounds of the widget. We can use thehitTest
method on the node for this.focus
on - I think thenode
is a natural choiceI'm open to other ideas for this (exposing
ref
always feels dirty 馃槃 ), but this can at least help us move forward on some of these other UI widgets.