requireNativeComponent was not found in the UIManager - React native (IOS)
Asked Answered
A

0

7

im building my npm package for ios, using native modules because i need to use a third party framework, the package is published and all good, installed to my app but when im about to render the native view from IOS to RN getting the error, heres in the IOS side:

this is my CounterViewManager.swift:

import Foundation

@objc(CounterViewManager)

class CounterViewManager: RCTViewManager {
  override func view() -> UIView! {
    let label = UILabel()
    label.text = "Swift Counter"
    label.textAlignment = .center
    return label
  }
}

my CounterViewManager.m:

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

@interface RCT_EXTERN_MODULE(CounterViewManager, RCTViewManager)
@end

and this how i import it from RN:

import { requireNativeComponent } from 'react-native';

const MyViewManager =  requireNativeComponent('CounterView');

export const Test = () => {

    return (
        <MyViewManager></MyViewManager>
    )
}

in RN i use CounterView because RN by default wont detect Manager at the end, but like i said always getting error that was not found in the UIManager, is driving me crazy, appreciate the help.

started the npm package following the docs: https://reactnative.dev/docs/native-modules-setup

when running in local to test works, can require the native module with that name, just when installing in my app via npm get that error

Allele answered 5/12, 2022 at 11:49 Comment(1)
Did you find a solution to this? I am also facing this issue.Aziza

© 2022 - 2024 — McMap. All rights reserved.