Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager

1.5k Views Asked by At

Trying to integrate react-native into my existing iOS application. Here are the contents of my package.json:

{
    "name": "MyReactNativeApp",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "yarn react-native start"
    },
    "dependencies": {
        "@react-native-community/viewpager": "^5.0.11",
        "axios": "^1.3.3",
        "react": "18.2.0",
        "react-native": "^0.71.3",
        "react-native-pager-view": "^6.1.4",
        "react-native-tab-view": "^3.5.0",
        "react-redux": "^8.0.5",
        "redux": "^4.2.1",
        "redux-thunk": "^2.4.2"
    }
}

I am able to build and run the application with all these libraries installed. When I am using tab view (which is dependent on react-native-pager-view), I get the following error:

Complete error:

Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager.

This error is located at: in RNCViewPager (created by PagerView) in PagerView (created by AnimatedComponent) in AnimatedComponent in AnimatedComponentWrapper (created by PagerViewAdapter) in PagerViewAdapter (created by TabView) in RCTView (created by View) in View (created by TabView) in TabView (created by App) in Provider (created by App) in App in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer in MyReactNativeApp(RootComponent), js engine: hermes

I've installed react-native-tab-view and react-native-pager-view and since i am using react-native 0.71.3, I do not need to link them manually.

Please help with this if any idea.

tried installing react-native-tab-view and react-native-pager-view. Also installed @react-native-community/viewpager (although deprecated)

1

There are 1 best solutions below

0
On BEST ANSWER

I observed that when i hit pod install, react-native-pager-view was not being installed. Here's what I found out:

I was using use_react_native! in my podfile. But since react-native-pager-view uses native modules (UIPageViewController in swift), you need to make sure that you enable native modules like this in your podfile:

config = use_native_modules!

# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

This worked for me.