AppProvider in Realm throws error saying “Can not read property of undefined”

In my React Native application, I am trying to wrap my app in AppProvider as i need to used Realm in my project. Whenever i try to do that, it throws error saying TypeError: Cannot read property 'prototype' of undefined. Here’s what i’m doing to wrap my app:

   <NavigationContainer
      ref={navigationRef}
      onReady={() => {
        isReadyRef.current = true;
      }}
      theme={isDarkMode ? DarkTheme : LightTheme}
    >
      <AppProvider id={"id"}>
        <UserProvider fallback={InstallManual}>
          <RealmProvider appId={appId}>
            <Stack.Navigator screenOptions={{ headerShown: false }}>
              <>
                <Stack.Screen name={SCREENS.INSTALLMANUAL}>
                  {(props) => <InstallManual {...props} />}
                </Stack.Screen>
                <Stack.Screen name={SCREENS.FORGET_PASSWORD}>
                  {(props) => <ForgetPasswordScreen {...props} />}
                </Stack.Screen>
              </>
            </Stack.Navigator>
          </RealmProvider>
        </UserProvider>
      </AppProvider>

 </NavigationContainer>

What am i doing wrong here ?