androidreact-nativereact-navigationreact-native-navigation

TypeError: el.getNode is not a function


I upgraded react-native version from v0.61.0 to 0.65.0 using rn community upgrade helper .

After making changes in the package.json file, running npm install, cleaning the build folder in android, the build gets successful and the app launches with an error screen.

TypeError: el.getNode is not a function

This error is located at:
    in AndroidHorizontalScrollView (at ScrollView.js:1784)
    in ScrollView (at ScrollView.js:1810)
    in ScrollView (at AnimatedScrollView.js:22)
    in Unknown (at createAnimatedComponent.js:243)
    in AnimatedComponent (at createAnimatedComponent.js:296)
    in AnimatedComponentWrapper (at TabBar.js:382)
    in RCTView (at View.js:32)
    in View (at TabBar.js:381)
    in RCTView (at View.js:32)
    in View (at createAnimatedComponent.js:243)
    in AnimatedComponent (at createAnimatedComponent.js:296)
    in AnimatedComponentWrapper (at TabBar.js:366)
    in TabBar (at MaterialTopTabBar.js:145)
    in TabBarTop (at createMaterialTopTabNavigator.js:101)
    in RCTView (at View.js:32)
    in View (at TabView.js:190)
    in TabView (at createMaterialTopTabNavigator.js:247)
    in MaterialTabView (at createTabNavigator.js:197)
    in NavigationView (at createNavigator.js:80)
    in Navigator (at RootTabs.js:218)
    in RootTabs (at SceneView.js:9)
    in SceneView (at DrawerView.js:188)
    in RCTView (at View.js:32)
    in View (at ResourceSavingScene.js:36)

I have also updated react-navigation from 3.x to 4.x.Still no success.
I am not able to understand what this snippet is referring to.

TypeError: el.getNode is not a function

I am struggling to run android as of now. Not tested on ios build.


Solution

  • I figured out that I was using the react-navigation-tabs package in my application.Go to node_modules > react-navigation-tabs > node_modules > react-navigation-tab-view > src > TabBar.js.

    In this TabBar.js file, you will find ref={el => (this._scrollView = el && el.getNode())} on line 412.

    If you check this._scrollView is assigned to _scrollView: ?ScrollView; on line 147 which is imported from ScrollView of react-native.

    Since ScrollView does not contain any el or el.getNode() method,the bundler throws the error showing el.getNode() is undefined.

    To fix this follow these steps:

    I was able to resolve this error by following this link

    Whosoever is getting this problem can refer to this link.