bmoneruxui bmoneruxui - 5 months ago 60
iOS Question

Initialization Errors with React Native Tutorials

I just installed React Native, and am attempting to follow tutorials on the React Native website to get accustomed to it. However every tutorial I end up doing just gives me a big red error screen in the iOS Simulator.

As an example, I followed the "Hello World" tutorial on the React Native website

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

class HelloWorldApp extends Component {
render() {
return (
<Text>Hello world!</Text>

AppRegistry.registerComponent('HelloWorldApp', () => HelloWorldApp);

but am met with this error after compiling and running in the simulator"

"Application TestProject has not been registered. This is either due to a require() error during initialization or failure to call AppRegistry.registerComponent"

I'm confused because I know nothing yet about RN, am following their tutorials to the letter, and am getting errors.

Please advise?


There might be two possibilities as I know of:

  1. When you run react-native run-ios the packager didn't start automatically. If that's the case, Run the Packager Manually. To do so:

In one Tab of your terminal run react-native start and in another run react-native run-ios.

  1. Or while following the document from react native's site, you might have changed the app's name. Like:

You created a project using react-native init AwesomeProject. The Project's name here is AwesomeProject.

And then changed your default index.ios.js and replaced the Component's name with HelloWorldApp.

class HelloWorldApp extends Component

AppRegistry.registerComponent('HelloWorldApp', () => HelloWorldApp);