React Native : null is not an object (evaluating 'NativeModules["SQLite"][method]')

564 Views Asked by At

I am trying to use the react-native-sqlite-storage library but I can't seem find any solution to this error. I have looked around for hours yet no solution seem to help me. If anyone could guild me through this, I'd really appreciate it.

Here is the screen where I am getting the error -

import { View, Text } from "react-native";
import { useEffect } from "react";
import React from "react";
import AsyncStorage from "@react-native-async-storage/async-storage";
import SQLite from "react-native-sqlite-storage";

const db = SQLite.openDatabase(
  {
    name: "userProfileDB",
    location: "default",
  },
  () => {
    console.log("succ");
  },
  (error) => {
    console.log("err");
  }
);

export default function ProfileScene() {
  return (
    <View>
      <Text>ProfileScene</Text>
    </View>
  );
}

Here is the error log -

TypeError: null is not an object (evaluating 'NativeModules["SQLite"][method]')

This error is located at:
    in ProfileScene (created by SceneView)
    in StaticContainer
    in EnsureSingleNavigator (created by SceneView)
    in SceneView (created by Drawer)
    in RCTView (created by View)
    in View (created by Screen)
    in RCTView (created by View)
    in View (created by Background)
    in Background (created by Screen)
    in Screen (created by Drawer)
    in RNSScreen (created by AnimatedComponent)
    in AnimatedComponent
    in AnimatedComponentWrapper (created by Screen)
    in MaybeFreeze (created by Screen)
    in Screen (created by MaybeScreen)
    in MaybeScreen (created by Drawer)
    in RNSScreenContainer (created by ScreenContainer)
    in ScreenContainer (created by MaybeScreenContainer)
    in MaybeScreenContainer (created by Drawer)
    in RCTView (created by View)
    in View (created by Drawer)
    in RCTView (created by View)
    in View (created by AnimatedComponent(View))
    in AnimatedComponent(View)
    in Unknown (created by Drawer)
    in RCTView (created by View)
    in View (created by AnimatedComponent(View))
    in AnimatedComponent(View)
    in Unknown (created by PanGestureHandler)
    in PanGestureHandler (created by Drawer)
    in Drawer (created by DrawerViewBase)
    in DrawerViewBase (created by DrawerView)
    in GestureHandlerRootView (created by GestureHandlerRootView)
    in GestureHandlerRootView (created by DrawerView)
    in RNCSafeAreaProvider (created by SafeAreaProvider)
    in SafeAreaProvider (created by SafeAreaInsetsContext)
    in SafeAreaProviderCompat (created by DrawerView)
    in DrawerView (created by DrawerNavigator)
    in Unknown (created by DrawerNavigator)
    in DrawerNavigator (created by App)
    in EnsureSingleNavigator
    in BaseNavigationContainer
    in ThemeProvider
    in NavigationContainerInner (created by App)
    in RCTView (created by View)
    in View (created by App)
    in App (created by ExpoRoot)
    in ExpoRoot
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent)
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/ReactFiberErrorDialog.js:52:4 in showErrorDialog
at node_modules/react-native/Libraries/Core/setUpReactRefresh.js:43:6 in Refresh.performReactRefresh
at node_modules/metro-runtime/src/polyfills/require.js:645:10 in setTimeout$argument_0

My system is Ubuntu 22.04, Node 16.15.1 and Expo 5.4.8.

0

There are 0 best solutions below