2

I'm following the example posted in the official doc for native module ios. I've set up everything, build it and run the application.

//  CAL.h    

#import <React/RCTBridgeModule.h>

@interface CAL : NSObject <RCTBridgeModule>

@end
// CAL.m

#import <React/RCTLog.h>
#import "CAL.h"

@implementation CAL

RCT_EXPORT_MODULE(CAL);

RCT_EXPORT_METHOD(createCalendarEvent:(NSString *)name location:(NSString *)location)
{
 RCTLogInfo(@"Pretending to create an event %@ at %@", name, location);
}
@end

But when I check NativeModules from react-native it shows an empty object - {}.

I'm not sure what I'm missing.

2
  • Try checking NativeModules.CAL directly Commented Oct 20, 2021 at 4:31
  • Yes that's what I had to do. Thanks Commented Oct 20, 2021 at 10:08

1 Answer 1

0

Like @chengsam mentioned, when I access CAL directly in the following manner it works.

const { CAL } = NativeModules; or NativeModules.CAL

CAL still held the native module while NativeModules directly displayed {}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.