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

Native UI Component throws Invariant Violation: tried to register two views with the same name FridgeCameraView

$
0
0

Trying to learn React Native custom Native UI Components.

// FridgeCameraViewManager.swift

import UIKit

@objc(FridgeCameraViewManager)
class FridgeCameraViewManager: RCTViewManager {

  override func view() -> UIView! {
    let label = UILabel()
    label.text = "Swift Component"
    label.textAlignment = .center
    return label
  }

  @objc static override func requiresMainQueueSetup() -> Bool {
    return false
  }
}

.

// FridgeCameraViewManager.h

#import <Foundation/Foundation.h>
#import "React/RCTViewManager.h"

@interface RCT_EXTERN_MODULE(FridgeCameraViewManager, RCTViewManager)


@end

.

// FridgeCameraView.js

import {requireNativeComponent} from 'react-native';
const FridgeCameraView = requireNativeComponent('FridgeCameraView', null);
export default FridgeCameraView;

When I try to use FridgeCameraView component somewhere in App.js, it works only If I build & run the project using Xcode. Otherwise, using hot reload when changing something, I get "Invariant Violation: tried to register two views with the same name FridgeCameraView".

enter image description here


Viewing all articles
Browse latest Browse all 16750

Trending Articles



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