2

Below is the code to initialize firebase application. I have installed firebase module with expo install firebase command. There are no errors when using web browser. But on Expo Go i get this errors below:

ReferenceError: Can't find variable: IDBIndex ...

Invariant Violation: "main" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called.

I'm new to node and react frameworks. Any advice will be helpful. Thanks

Should i update babel.config.json ? If yes, how ?

App.tsx

import { Component } from "react";
import {
  DarkTheme as PaperDarkTheme,
  DefaultTheme as PaperDefaultTheme,
  Provider as PaperProvider,
} from "react-native-paper";

import {
  NavigationContainer,
  DarkTheme as NavigationDarkTheme,
  DefaultTheme as NavigationDefaultTheme,
} from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";

import { FirebaseApp, initializeApp } from "firebase/app";

import AppHeader from "./Components/AppHeader";
import ScreenHome from "./Components/ScreenHome";

export default class App extends Component<{}, {}> {
  app: FirebaseApp;
  constructor(props: any) {
    super(props);
    this.app = initializeApp(firebaseConfig);
    this.state = {};
    this.handleEvent = this.handleEvent.bind(this);
  }

  handleEvent() {
    console.log(this.props);
  }

  render() {
    return (
      <PaperProvider theme={CombinedDefaultTheme}>
        <NavigationContainer theme={CombinedDefaultTheme}>
          <Stack.Navigator initialRouteName="Home">
            <Stack.Screen
              component={ScreenHome}
              name="Home"
              options={({ navigation, route }) => ({
                header: (props) => <AppHeader navigation={navigation} />,
              })}
            />
          </Stack.Navigator>
        </NavigationContainer>
      </PaperProvider>
    );
  }
}

const CombinedDarkTheme = {
  ...PaperDarkTheme,
  ...NavigationDarkTheme,
  colors: {
    ...PaperDarkTheme.colors,
    ...NavigationDarkTheme.colors,
  },
};

const CombinedDefaultTheme = {
  ...PaperDefaultTheme,
  ...NavigationDefaultTheme,
  colors: {
    ...PaperDefaultTheme.colors,
    ...NavigationDefaultTheme.colors,
    accent: "yellow",
    primary: "tomato",
  },
};

const firebaseConfig = {##};

const Stack = createStackNavigator();

babel.config.json

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    env: {
      production: {
        plugins: ["react-native-paper/babel"],
      },
    },
  };
};
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Sourcer0X
  • 21
  • 3
  • You do not import firebaseConfig – Gismo1337 Mar 05 '22 at 08:34
  • @Gismo1337 i've the config on bottom of the page. replaced entries with ## to share – Sourcer0X Mar 05 '22 at 13:05
  • oh. excuse me. i did not saw that text at bottom. may this helps: https://github.com/expo/expo/issues/9042 or this https://www.reddit.com/r/reactnative/comments/o9nqpk/invariant_violation_main_has_not_been_registered/ – Gismo1337 Mar 05 '22 at 16:22
  • @Gismo1337 looks like there's no workaround for managed code yet. – Sourcer0X Mar 05 '22 at 20:24
  • This is a known issue on some non-browser environments with the most recent release of the Firebase SDKs. Check my [answer](https://stackoverflow.com/a/71414517/209103) to the question I linked for more info, and a link to the Github [issue](https://github.com/firebase/firebase-js-sdk/issues/6042) where it's being tracked – Frank van Puffelen Mar 09 '22 at 19:32

0 Answers0