Reputation: 1559
i have my own native component and it works great. I would like to add a method to expose some value and i am not sure how this works, can i use RCT_EXPORT_METHOD on a view and if so how do i access it?
@implementation MyEditorManager {
}
RCT_EXPORT_VIEW_PROPERTY(initialValue, NSString)
RCT_EXPORT_VIEW_PROPERTY(staticText, NSString)
RCT_EXPORT_MODULE()
// i would like to call this !!!
RCT_EXPORT_METHOD(hello:(NSString *)name) {
}
- (UIView *)view
{
_field = [[RichTextEditor alloc] init];
_field.delegate = self;
return _field;
}
I would like to call this method hello. But i am not sure how to. My integration with react native looks like this.
var { requireNativeComponent } = require('react-native');
var React = require('react-native');
class MyEditor extends React.Component {
render() {
return (
<Comp {...this.props} />
);
}
};
var Comp = requireNativeComponent('MyEditor', MyEditor,
{ nativeOnly: { onChange: true } } );
module.exports = MyEditor;
Ideally i would like to do something like that, but it does not work
// in render
<Editor ref='editor' />
// ...
// later call this.refs.hello('test')
Any help would be greatly appreciated!
Upvotes: 0
Views: 1275
Reputation: 3685
You should be able to call it like this:
var Comp = requireNativeComponent('MyEditor', MyEditor, { nativeOnly: { onChange: true } } )
Comp.hello('test')
Upvotes: 0