fix(ios): make event emit() templates compatible with RN 0.85+#77
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
React Native 0.85 (shipped in Expo SDK 56) changed
facebook::react::SharedEventEmitterfromshared_ptr<const EventEmitter>toshared_ptr<EventEmitter>(const dropped).RCTViewComponentViewstill holds_eventEmitterasSharedViewEventEmitter(shared_ptr<const ViewEventEmitter>), so the implicit conversion fromshared_ptr<const ViewEventEmitter>to the new non-constSharedEventEmitterno longer compiles —shared_ptrwon't strip const implicitly.This PR templatizes the holder parameter on each event's
emit()so the type is deduced from the call site. Thestatic_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
Test Plan
_eventEmitter, now builds clean.example/barestill on RN 0.83.0 — backward-compatible: the templated holder deduces to the oldSharedEventEmitterand behaves identically.Screenshots / Videos
N/A — C++ header-only change.
Checklist