I am getting the following error when trying to invoke a method in a Native Module:
'undefined' is not an object (evaluating 'ScaleController. updateScaleFromJSON')
My native module Objective-C files -
RCTScaleController.h:
#ifndef RCTScaleController_h
#define RCTScaleController_h
#import "RCTBridgeModule.h"
@interface RCTScaleController : NSObject <RCTBridgeModule>
@end
#endif /* RCTScaleController_h */
RCTScaleController.mm:
#import "RCTScaleController.h"
#import "ScaleControllerObjC.h"
#import "RCTLog.h"
@implementation RCTScaleController
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(updateScaleFromJSON:(NSString *)jsonString)
{
RCTLogInfo(@"About to send json: %@", jsonString);
ScaleControllerObjC *scaleController = [[ScaleControllerObjC alloc] init];
[scaleController updateScaleFromJSON:jsonString];
}
Here it is being required in my JS file:
var ScaleController = require('react-native').NativeModules.RCTScaleController;
And here it is being invoked causing the error:
ScaleController.updateScaleFromJSON (JSON.stringify (scale));
I've followed the examples I've seen and not sure whats wrong here..