Ad

React Navgiation AppRegistry Is Not Registered

- 1 answer

I have setup a brand new project using react-native init <proj> and it builds fine. I have added react-navigation to the project following the docs. However, I cannot get passed this error:

Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

Even using the single file stack example from their documentation:

import React from 'react';
import { View, Text } from 'react-native';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';

class HomeScreen extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Home Screen</Text>
      </View>
    );
  }
}

const AppNavigator = createStackNavigator({
  Home: {
    screen: HomeScreen,
  },
});

export default createAppContainer(AppNavigator);

It does not work. I am at a loss to what the issue could be here as I am using a base install with their working example and nothing else added. I have tried everything from restarting the bundler to clearing all caches I can think of.

Ad

Answer

Make sure you're registering the component:

const App = createAppContainer(navigator):

AppRegistry.registerComponent(appName, () => App)
Ad
source: stackoverflow.com
Ad