Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Why is my Swfit native ui component not receiving props from React Native?

$
0
0

I'm trying to bridge my swift UI view to react-native. The component is being passed to RN correctly and mounts but I am unable to receive any props that I pass. I'm using react-native@0.59.10. I've found the documentation to be patchy and various other resources online have different methods that I've tried to no avail so any help is greatly appreciated.

RNGallery360-Bridging-Header.h

#ifndef RNGallery360_Bridging_Header_h
#define RNGallery360_Bridging_Header_h

    #import <React/RCTBridgeModule.h>
    #import <React/RCTViewManager.h>

#endif

RNGallery360.m

#import <React/RCTViewManager.h>

@interface RCT_EXTERN_MODULE(Gallery360ViewManager, RCTViewManager)
    RCT_EXPORT_VIEW_PROPERTY(width, NSInteger)
    RCT_EXPORT_VIEW_PROPERTY(height, NSInteger)
@end

Gallery360ViewManager.swift

import Foundation

@objc(Gallery360ViewManager)
class Gallery360ViewManager: RCTViewManager {
  @objc var width : NSInteger = 0
  @objc var height : NSInteger = 0

  override func view() -> UIView! {
    print("I am the width & height", width, height) // this consistently returns 0, 0
    return Gallery360(width: width, height: height)
  }

  override static func requiresMainQueueSetup() -> Bool {
    return true
  }
}

Gallery360.swift

import Foundation

@objc(Gallery360)
class Gallery360 : UIView  {
    @objc
    public convenience init(width:NSInteger, height:NSInteger) {
        self.init(frame:CGRect(x: 0, y: 0, width: width, height: height))
    }
}

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>