How to define entry point for react native app

if you are using Expo, you have to specify the entrypoint in your app.json file like this:

{
  "expo": {
    "entryPoint": "./src/app/index.js"
  }
}

then, inside that file you need to register the app with Expo.registerRootComponent(YOUR_MAIN_APP_COMPONENT)

import Expo from 'expo'
...

class App extends Component {
  ...
}

export default Expo.registerRootComponent(App);

this way you can add your entry file wherever you want.


You need to update the app.json so that the entryPoint is the new path to the App.js.

{
  "expo": {
    "entryPoint": "./src/App.js",
    ...
  }
}

However using Expo.registerRootComponent(App) causes the following error in SDK 32:

undefined is not an object (evaluating '_expo.default.registerRootComponent') 

It can be fixed by importing registerRootComponent explicitly, rather than trying to access it via Expo.registerRootComponent.

Here is a sample App.js.

import { registerRootComponent } from 'expo';

class App extends React.Component {
  ...
}

export default registerRootComponent(App);