AppRegistry.registerComponent() not working with Expo

Viewed 4862

I use to set the main file of my project using AppRegistry.registerComponent(), but projects created with Expo does not support it.

import { AppRegistry } from 'react-native';
import App from './src/App';

AppRegistry.registerComponent('my App', () => App);

Then, I use src/App.js as my main file. How can I do it using Expo?

Thanks

1 Answers

Straight from React Native docs facebook.github.io/react-native/docs/appregistry

AppRegistry is the JS entry point to running all React Native apps. App root components should register themselves with AppRegistry.registerComponent, then the native system can load the bundle for the app and then actually run the app when it's ready by invoking AppRegistry.runApplication.

In other words, since Expo isn't a complete real app because it's running on your device Expo app, doesn't have many methods available for you from react-native. Read Expo's docs for more information.

You only need on your App.js:

import React from 'react';
import { View, Text } from 'react-native';

export default () => (
   <View>
     <Text>Some Text</Text>
   </View>
);

Check out this snack: @abranhe/stackoverflow-56694295

Related