fix(ios): change event handlers to RCTDirectEventBlock(#24)#25
Merged
theashraf merged 1 commit intoLottieFiles:mainfrom Oct 21, 2025
Merged
Conversation
Fixes event re-registration warnings in iOS when using SwiftUI implementation. Changes RCTBubblingEventBlock to RCTDirectEventBlock for all animation events to match React Native's event naming conventions (top* prefix). Resolves LottieFiles#24
|
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.
iOS generates multiple console warnings when importing or using the DotLottie component in v0.6.0:
Stacktrace
These warnings pollute the console during development and indicate incorrect event registration.
Root Cause
React Native automatically converts event names from
onLoad→topLoad, which follows the direct event naming convention (top*prefix).However, all animation events in
ios/DotlottieReactNativeViewManager.mare registered asRCTBubblingEventBlock:This creates a mismatch between:
topLoad(suggests direct event)RCTBubblingEventBlock(bubbling event)This issue appeared in v0.6.0 after the iOS implementation was migrated to SwiftUI. v0.5.0 didn't have this issue.
✅ Solution
Changed animation event handlers from
RCTBubblingEventBlocktoRCTDirectEventBlockinios/DotlottieReactNativeViewManager.m:RCT_EXPORT_VIEW_PROPERTY(onPlay, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onPause, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onStop, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onLoop, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onFrame, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onRender, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onComplete, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onLoadError, RCTDirectEventBlock)This aligns with React Native's event naming conventions and makes semantic sense - animation lifecycle events don't need to bubble up to parent components.
🧪 Testing
onLoad,onComplete,onPlay, etc.) fire correctly