Skip to content

fix(ios): make event emit() templates compatible with RN 0.85+#77

Merged
lodev09 merged 1 commit into
mainfrom
fix/ios-event-emitter-rn-0.85-compat
May 26, 2026
Merged

fix(ios): make event emit() templates compatible with RN 0.85+#77
lodev09 merged 1 commit into
mainfrom
fix/ios-event-emitter-rn-0.85-compat

Conversation

@1kuko3
Copy link
Copy Markdown
Contributor

@1kuko3 1kuko3 commented May 26, 2026

Summary

React Native 0.85 (shipped in Expo SDK 56) changed facebook::react::SharedEventEmitter from shared_ptr<const EventEmitter> to shared_ptr<EventEmitter> (const dropped). RCTViewComponentView still holds _eventEmitter as SharedViewEventEmitter (shared_ptr<const ViewEventEmitter>), so the implicit conversion from shared_ptr<const ViewEventEmitter> to the new non-const SharedEventEmitter no longer compiles — shared_ptr won't strip const implicitly.

This PR templatizes the holder parameter on each event's emit() so the type is deduced from the call site. The static_pointer_cast<Emitter const>(...) body works unchanged for both old and new RN versions. No call site changes are needed because the second template parameter is deduced.

We hit this downstream when integrating @lugg/maps with Expo SDK 56 / RN 0.85.3 and have been carrying it as a patches/ override.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

  • Compiled the package against RN 0.85.3 (Expo SDK 56) in our consumer app — previously failed with const-conversion error on _eventEmitter, now builds clean.
  • example/bare still on RN 0.83.0 — backward-compatible: the templated holder deduces to the old SharedEventEmitter and behaves identically.

Screenshots / Videos

N/A — C++ header-only change.

Checklist

  • I tested on iOS
  • I tested on Android (no changes — Android dispatches events from Kotlin)
  • I tested on Web (N/A)
  • I updated the documentation (not needed — internal C++ signature, not a public API)

React Native 0.85 changed facebook::react::SharedEventEmitter from
shared_ptr<const EventEmitter> to shared_ptr<EventEmitter>. RCTViewComponentView
still holds _eventEmitter as SharedViewEventEmitter (shared_ptr<const
ViewEventEmitter>), so the const-stripping implicit conversion stops compiling.

Templatize the holder type on each event's emit() so the deduced argument matches
whatever the call site provides. Backward-compatible with RN <0.85.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lodev09 lodev09 merged commit 9ac403c into main May 26, 2026
3 checks passed
@lodev09 lodev09 deleted the fix/ios-event-emitter-rn-0.85-compat branch May 26, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants