SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

Fix dispatching into incorrect UIManager type when event's target is a root view (#36659)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36659

## Changelog:

[Android][Fixed] - Fix dispatching into incorrect UIManager type when event's target is a root view

There is a function, called [ViewUtil.getUIManagerType](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java#L22), which infers whether we are using the new or old architecture, given a View tag ID, with the assumption being that all New Architecture tags are even (and therefore, we are in the New Architecture iff the view tag is even). See [here for more context](https://github.com/facebook/react/pull/12587/files).

This function was used to find out which type of event dispatcher to dispatch to, when going down the chain of event dispatching function calls on Android.

The problem is, that there may be cases, when this odd/even assumption breaks, in particular when the target view ID is equal to `1`, meaning that it's a root view ID and there is nothing else mounted there yet.

It's very rare that this happens in practice, but still is possible that user interacts with the screen before anything is mounted there (or if there is nothing mounted there by design).

Reviewed By: javache

Differential Revision: D44421739

fbshipit-source-id: fd5ba3c882f6c7d3c9543ebc2ec30ba000f7ca4f
R
Ruslan Shestopalyuk committed
871f294bcbed43f757606b8fb97c01abbb063b97
Parent: f708cc4
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 3/28/2023, 10:08:13 AM