diff --git a/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h index 3e9aa922776b61..54056606cbe756 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h @@ -169,7 +169,8 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { ShadowNodeFamily::Shared createFamily( const ShadowNodeFamilyFragment& fragment) const override { auto eventEmitter = std::make_shared( - std::make_shared(fragment.instanceHandle), + std::make_shared( + fragment.instanceHandle, fragment.surfaceId), eventDispatcher_); return std::make_shared( fragment, std::move(eventEmitter), eventDispatcher_, *this); diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventTarget.cpp b/packages/react-native/ReactCommon/react/renderer/core/EventTarget.cpp index c864960c6f41e5..83ed43b8653688 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventTarget.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/EventTarget.cpp @@ -13,8 +13,11 @@ namespace facebook::react { using Tag = EventTarget::Tag; -EventTarget::EventTarget(InstanceHandle::Shared instanceHandle) +EventTarget::EventTarget( + InstanceHandle::Shared instanceHandle, + SurfaceId surfaceId) : instanceHandle_(std::move(instanceHandle)), + surfaceId_(surfaceId), strongInstanceHandle_(jsi::Value::null()) {} void EventTarget::setEnabled(bool enabled) const { @@ -64,6 +67,10 @@ jsi::Value EventTarget::getInstanceHandle(jsi::Runtime& runtime) const { return jsi::Value(runtime, strongInstanceHandle_); } +SurfaceId EventTarget::getSurfaceId() const { + return surfaceId_; +} + Tag EventTarget::getTag() const { return instanceHandle_->getTag(); } diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventTarget.h b/packages/react-native/ReactCommon/react/renderer/core/EventTarget.h index 1d65d7cd9fad50..e08ddcab047395 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventTarget.h +++ b/packages/react-native/ReactCommon/react/renderer/core/EventTarget.h @@ -34,7 +34,9 @@ class EventTarget { /* * Constructs an EventTarget from a weak instance handler and a tag. */ - explicit EventTarget(InstanceHandle::Shared instanceHandle); + explicit EventTarget( + InstanceHandle::Shared instanceHandle, + SurfaceId surfaceId); /* * Sets the `enabled` flag that allows creating a strong instance handle from @@ -59,6 +61,8 @@ class EventTarget { */ jsi::Value getInstanceHandle(jsi::Runtime& runtime) const; + SurfaceId getSurfaceId() const; + /* * Deprecated. Do not use. */ @@ -66,6 +70,7 @@ class EventTarget { private: const InstanceHandle::Shared instanceHandle_; + const SurfaceId surfaceId_; mutable bool enabled_{false}; // Protected by `EventEmitter::DispatchMutex()`. mutable jsi::Value strongInstanceHandle_; // Protected by `jsi::Runtime &`. mutable size_t retainCount_{0}; // Protected by `jsi::Runtime &`.