AlexanderZaytsev / react-native-i18n

React Native + i18n.js
MIT License
2.18k stars 493 forks source link

Getting Invariant Violation: "main" has not been registered error #276

Closed asmode111 closed 3 years ago

asmode111 commented 3 years ago

Package.json

...
 "expo": "^39.0.4",
 "react-native": "~0.63.3",
 "react-native-i18n": "^2.0.15",
...

App.js

// other imports
import I18n from "react-native-i18n";

I18n.fallbacks = true;

I18n.translations = {
  en: {
    greeting: "Hi!",
  },
  fr: {
    greeting: "Bonjour!",
  },
};

return <Text>{I18n.t("greeting")}</Text>;

index.js

import { registerRootComponent } from "expo";
import App from "./App";
registerRootComponent(App);

When I run expo start, I am getting the error below on the ios simulator. If I don't import the react-native-i18n library, the app works as expected without any error.

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.
- node_modules/react-native/Libraries/LogBox/LogBox.js:148:8 in registerError
- node_modules/react-native/Libraries/LogBox/LogBox.js:59:8 in errorImpl
- node_modules/react-native/Libraries/LogBox/LogBox.js:33:4 in console.error
- node_modules/expo/build/environment/react-native-logs.fx.js:27:4 in error
- node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
- node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
- node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
...