[Native] Add FeatureFlag to dispatch events with instance targets#17323
Merged
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 43fad6e:
|
Details of bundled changes.Comparing: 01bce8c...43fad6e react-native-renderer
Size changes (stable) |
Details of bundled changes.Comparing: 01bce8c...43fad6e react-native-renderer
Size changes (experimental) |
Contributor
Author
|
This PR depends on #17344 to change the flow types to allow null as the target. |
Contributor
Author
|
|
sebmarkbage
approved these changes
Nov 11, 2019
elicwhite
force-pushed
the
native-event-target
branch
from
November 11, 2019 19:23
76aff65 to
43fad6e
Compare
elicwhite
added a commit
to elicwhite/react
that referenced
this pull request
Dec 19, 2019
…act#17323) * [Native] Add FeatureFlag to dispatch events with instance targets * Prettier
elicwhite
added a commit
to elicwhite/react
that referenced
this pull request
Jan 8, 2020
…act#17323) * [Native] Add FeatureFlag to dispatch events with instance targets * Prettier
mrizwanashiq
pushed a commit
to mrizwanashiq/react
that referenced
this pull request
Jun 25, 2026
…act#17323) * [Native] Add FeatureFlag to dispatch events with instance targets * Prettier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In React Native we want to try making the event target and currentTarget equal to a React Instance instead of a reactTag. This is needed to clean up some of the logic in ScrollResponder, TextInput, and TextInputState. This also will let these core components become compatible with Fabric.
There is precedent here as target and currentTarget on ReactDOM are HTMLElements that have .focus and .blur methods for example.
This API is behind a FeatureFlag that we can use to run an experiment internally.
It is worth noting that this will be a breaking change to ReactNative when rolled out. When searching the Facebook codebase I surprisingly found essentially no callsites referencing target/currentTarget except for our core components. That gives me some confidence that this breaking change is acceptable and doesn't require a different approach like putting the instance in a different key on the event.
The purpose of this experiment is to validate that assumption.
Note: This PR doesn't have any logic to change
currentTarget. I haven't investigated that one yet to know how to change that. Is that reasonable to do in a separate PR or do you think it should be part of the same one?Test Plan
I did a local sync and ran these changes in the Facebook repo and tested this in both Fabric and Paper with the flag turned on and off. ScrollResponder and TextInput logic didn't throw any exceptions, was correctly handling target being both a number and instance.