Hi friend! Meet us at App.js Conf in Krakow, Poland on April 4th and 5th with workshops and talks. Learn more
Sets the main component for Expo to use for your app.
Note: Prior to SDK 18, it was necessary to use registerRootComponent directly, but for projects created as of SDK 18 or later, this is handled automatically in the Expo SDK.
component (ReactComponent) -- The React component class that renders the rest of your app.
No return value.
Note:Expo.registerRootComponent is roughly equivalent to React Native's AppRegistry.registerComponent, with some additional hooks to provide Expo specific functionality.
I created my project before SDK 18 and I want to remove Expo.registerRootComponent, how do I do this?
Before continuing, make sure your project is running on SDK 18 or later.
Open up main.js (or if you changed it, whatever your "main" is in package.json).
Set "main" to "node_modules/expo/AppEntry.js".
Delete the Expo.registerRootComponent call from main.js and put export default before your root component's class declaration.
Rename main.js to App.js.
What if I want to name my main app file something other than App.js?
You can set the "main" in package.json to any file within your
project. If you do this, then you need to use registerRootComponent;
export default will not make this component the root for the Expo app
if you are using a custom entry file.
For example, let's say you want to make "src/main.js" the entry file
project root, for example. First, set this in package.json:
Then in "src/main.js", make sure you call registerRootComponent and
pass in the component you want to render at the root of the app.