Skip to content

[RN] Call dispatchNativeEvent when the event target is null - #38007

Merged
rubennorte merged 2 commits into
react:mainfrom
lazerg:fix/issue-38006-null-event-target
Oct 27, 2026
Merged

rubennorte merged 2 commits into
react:mainfrom
lazerg:fix/issue-38006-null-event-target

Conversation

@lazerg

@lazerg lazerg commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

With enableNativeEventTargetEventDispatching on, the Fabric renderer skipped dispatchNativeEvent when the touched view had already unmounted, so the touch end never reached the JS responder and the next tap got lost. This passes the null target through instead, so React Native can still release the responder. It needs react/react-native#59522 to land first, since dispatchNativeEvent there throws on a null target today.

Fixes #38006

How did you test this change?

Added a test in ReactFabric-test.internal.js that unmounts a view, dispatches a touch end to its old instance handle, and expects dispatchNativeEvent to get a null target. It fails on main and passes with this change. Also ran yarn test packages/react-native-renderer (default, --prod, www-modern), yarn flow fabric, yarn linc and yarn prettier-check.

@meta-cla meta-cla Bot added the CLA Signed label Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Comparing: fd51cb1...e7ce80f

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 7.35 kB 7.35 kB -0.05% 1.96 kB 1.96 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 626.13 kB 626.13 kB = 110.64 kB 110.64 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 7.36 kB 7.36 kB -0.05% 1.96 kB 1.96 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 697.35 kB 697.35 kB = 122.08 kB 122.08 kB
facebook-www/ReactDOM-prod.classic.js = 715.38 kB 715.38 kB = 125.15 kB 125.15 kB
facebook-www/ReactDOM-prod.modern.js = 705.70 kB 705.70 kB = 123.58 kB 123.58 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by sizebot against e7ce80f

Comment thread scripts/flow/react-native-host-hooks.js Outdated
): ?Object;
declare export function dispatchNativeEvent(
target: EventTarget,
target: null | EventTarget,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: more resilient as target: ?EventTarget

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e7ce80f, thanks.

@rubennorte rubennorte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@rubennorte
rubennorte merged commit dc9aed3 into react:main Oct 27, 2026
239 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 27, 2026
## Summary

With `enableNativeEventTargetEventDispatching` on, the Fabric renderer
skipped `dispatchNativeEvent` when the touched view had already
unmounted, so the touch end never reached the JS responder and the next
tap got lost. This passes the null target through instead, so React
Native can still release the responder. It needs
react/react-native#59522 to land first, since `dispatchNativeEvent`
there throws on a null target today.

Fixes #38006

## How did you test this change?

Added a test in `ReactFabric-test.internal.js` that unmounts a view,
dispatches a touch end to its old instance handle, and expects
`dispatchNativeEvent` to get a null target. It fails on main and passes
with this change. Also ran `yarn test packages/react-native-renderer`
(default, `--prod`, www-modern), `yarn flow fabric`, `yarn linc` and
`yarn prettier-check`.

DiffTrain build for [dc9aed3](dc9aed3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Fabric renderer should call dispatchNativeEvent when the event target is null

3 participants