New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Native module cannot be null.", but only if module name begins with "RCT"! #19397
Comments
Some Note that I expose and invoke the method Named as
|
If I understand correctly I think this behavior related to this chunk of code: https://github.com/facebook/react-native/blob/0.55-stable/React/Base/RCTBridge.m#L80 By default, RN strip "RCT" prefix from module names... this is old behavior, as I know it was born to make useful names for standard modules... so standard module |
I see, so I would simply access my native component externally exposed as 'RCTCalendarManager', in JavaScript with the truncated name 'CalendarManager'? If this is indeed the logic, then I don't feel that this necessitates any core code changes; clear documentation of this matter in the Native Modules docs would suffice. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
Environment
Steps to Reproduce
Update minimum working example to latest dependencies
react-native
dependency to the latest versionopen ios/SwiftBridge.xcodeproj
constantsToExport()
function in bothios/CalendarManager.swift
andios/CalendarManager.m
. It is not called byindex.ios.js
, in any case!Update the Build Phases > Bundle React Native code and images
script as specified.Run with modules named
CalendarManager
and alternativelyRCTCalendarManager
ios/CalendarManager.swift
,ios/CalendarManager.m
andindex.ios.js
. No need to change their file names.Expected Behavior
I would be able to use names beginning with
RCT
as React Native modules, or at least see some mention of it in the documentation. It took me days to figure out the root of this bug, and I wouldn't mind this naming restriction if only it were documented.EDIT: Note that I have tried other module names, such as "CTCalendarManager", and they all work. It really is specifically a problem with the "RCT" prefix.
Actual Behavior
This error message is emitted:
Calling
console.log(NativeModules)
just returns an empty object.The text was updated successfully, but these errors were encountered: