Files
Zeya Peng 5d1eac047a add RNTester example for native command Array param (#41897)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41897

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D51875073

fbshipit-source-id: 403274b3063d7c49fe4642347d2f724d58a46c1f
2023-12-14 21:06:09 -08:00

45 lines
1.1 KiB
Plaintext

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <React/RCTLog.h>
#import <React/RCTUIManager.h>
#import <React/RCTViewManager.h>
#import "UIView+ColorOverlays.h"
@interface RNTMyNativeViewManager : RCTViewManager
@end
@implementation RNTMyNativeViewManager
RCT_EXPORT_MODULE(RNTMyNativeView)
RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(onIntArrayChanged, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(values, NSArray *)
RCT_EXPORT_METHOD(callNativeMethodToChangeBackgroundColor : (nonnull NSNumber *)reactTag color : (NSString *)color)
{
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
UIView *view = viewRegistry[reactTag];
if (!view || ![view isKindOfClass:[UIView class]]) {
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
return;
}
[view setBackgroundColorWithColorString:color];
}];
}
- (UIView *)view
{
return [[UIView alloc] init];
}
@end