IOS: You must override the supportedEvents
method Error thrown when supportedEvents
is implemented in super class
#20687
Labels
Platform: iOS
iOS applications.
Ran Commands
One of our bots successfully processed a command.
Resolution: Locked
This issue was locked by the bot.
Environment
Environment:
OS: macOS High Sierra 10.13.2
Node: 9.11.1
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.2 => 0.55.2
Description
RCTEventEmitter has a check implemented in class initializer to check that the Implementation being created implements 'supportedEvents' method. this is achieved here
But the
RCTClassOverridesInstanceMethod
method defined here usesclass_copyMethodList
obj-C Runtime method to get instance methods and iterate over them to see if required method is implemented.as per Apple Docs
class_copyMethodList
does NOT return instance methods implemented by super classes.This causes the app to crash in Dev mode (because of RCTAssert?) if the app has its own hierarchy of
RCTEventEmitter
s, in which case thesupportedEvents
is implemented by an intermediate superclass between the current class andRCTEventEmitter
.IMO, the implementation should walk the inheritance hierarchy till
RCTEventEmitter
to make the correct assertion.Reproducible Demo
Create a Native Module with One
BaseEmitter
which extends fromRCTEventEmitter
implement all the required functionalities also thesupportedEvents
method. Now create another classMainEmitter
which extends fromBaseEmitter
, do not implement thesupportedEvents
method inMyEmitter
to re-use implementation fromBaseEmitter
App will crash on first use of
MainEmitter
The text was updated successfully, but these errors were encountered: