How to registerRootComponent with component App inside a function (cause of Mobx)

Hello everyone,

When I publish my expo project, I have the the error “Uncaught error : Application main has not been registered”. So it seems that I have to register my main component.

My problem is that my main app component is inside a function because I use Mobx and I have to send my stores inside. Here is my react.tsx :

import React from 'react';
import { Provider } from 'mobx-react';
import Routes from '../container/routes';
import FlashMessage from 'react-native-flash-message';
import { ThemeProvider } from 'react-native-elements';

export default function(stores: any) {
	return class App extends React.Component {
		render() {
			return (
						<Provider {...stores}>
							<Routes />
						<FlashMessage position="top" />

Then I have an index.tsx :

import mobx from './mobx';
import components from './react';

export default function() {
	const stores = mobx();
	return components(stores);

Which is used in an app.tsx :

import boot from './boot/index';

const app = boot();

export default app;

And last, but not least, my App.js file :

import app from './src/app';

export default app;

So I would like to use the registerRootComponent(App); function to register the App component. But I tried to use it in the react.tsx file, in the App.tsx file, but each time I have the same error “main application non registered”…

Do you have any idea how I could register my component ? I would be so happy if you find the solution :slight_smile:

I use the SDK 34.0.0, and I develop the app for iOS and Android, if these informations could be importants.

Thank you all for the expo project !

Hi, @julienblc

I know practically nothing about Mobx. Does this perhaps help?

Here’s another Mobx + React Native example, although it’s a few years old. And another.

No, actually it was my fault. The sdk 34 already handle this, and the problem was with my env variables… The error message was wrong, but it was not cause of the registerRootComponent.
I found my solution here :

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.