You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3aed172
Browse filesBrowse the repository at this point in the historyBrowse files
Forward RCTEventDispatcher observer events to C++ Native Animated
Summary:
**Problem**: With C++ Native Animated enabled on iOS, native-driven `Animated.event` mappings no longer receive events that libraries deliver through `RCTEventDispatcher` observers. The legacy ObjC Native Animated module observed them; C++ Native Animated only reads Fabric event payloads (event dispatched with `eventEmitter->dispatchEvent(name, folly::dynamic)`), and codegen'd component events are not readable from C++.
As a result, in some of `react-navigation` (oss library) examples, Gesture- and pager-driven animations (swipe-back in a JS stack navigator, tab indicators driven by a pager's `onPageScroll`) stop tracking user input.
**Proposed change**: When C++ Native Animated is enabled, `RCTInstance` observes its `RCTEventDispatcher` and hands each component event, on the main thread, to an `EventEmitterListenerContainer` it publishes in the context container under `RCTEventDispatcherListeners`. On Apple platforms, `NativeAnimatedNodesManagerProvider::getOrCreate()` adds its event listener to that container when present, next to its Fabric event listener.
An **alternative** is to let the library migrate to `EventEmitter::dispatchEvent` (so we fully get rid of the legacy event API); however dispatchEvent also delivers the event to JS. In android and RNCXX, we also maintain 2 paths to intercept js dispatchEvent and platform-only event.
**Changes**:
- iOS (`RCTInstance`, new `RCTEventDispatcherEventPayload`): registers as an `RCTEventDispatcherObserver` only when `cxxNativeAnimatedEnabled()` is on, and forwards only component events (`RCTEventEmitter.receiveEvent`). The payload reads values from the event body on demand, so events no listener reads are not converted; it is never dispatched to JS.
- C++ (`NativeAnimatedNodesManagerProvider`, `__APPLE__` only): subscribes to `RCTEventDispatcherListeners` from the UIManager's context container. Covers the platform-driven and shared animation backend setups, and apps that create their own provider.
- C++: `EventEmitterListener.h` moves from `react/renderer/animated` to `react/renderer/core` (the runtime only needs `core`); `react/renderer/animated/EventEmitterListener.h` forwards to it for existing includers.
No public API changes.
Found while auditing `cxxNativeAnimatedEnabled` against OSS react-navigation (7.x) and its peers react-native-gesture-handler, react-native-pager-view and react-native-screens.
Changelog:
[iOS][Fixed] - Native-driven `Animated.event` mappings receive events delivered through `RCTEventDispatcher` observers when C++ Native Animated is enabled
Reviewed By: fkgozali
Differential Revision: D129152896
Pull Request resolved: #59770
0 commit comments