Search code examples
objective-creact-native

React Native: Native Modules Props


I'm trying to make a Native Module in React Native. How can I access the URL in the view?

const MyView = requireNativeComponent('RNTImageFilter');
<MyView 
                    uri={'test'}
                    style={{borderWidth: 1, borderColor: 'red', height: 200, width: 200}}
                    />

ObjC:

@interface RNTImageFilterManager : RCTViewManager
@property (nonatomic, strong) NSString *uri;
@end

@implementation RNTImageFilterManager

RCT_EXPORT_MODULE(RNTImageFilter)


- (UIView *)view
{
    UIView *picker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, 260)];
    picker.backgroundColor = [UIColor blueColor];
    NSLog(@"%@", self.uri);
    
    return picker;
}

RCT_EXPORT_VIEW_PROPERTY(uri, NSString *);

@end

thanks!


Solution

  • Got it!

    RCT_CUSTOM_VIEW_PROPERTY(uri, NSString, RNTImageFilterManager) {
        NSLog(@"%@", json);
    }