I guess it is an error caused by not matching name of project and your registered component.
You have inited project with one name, i.e.
react-native init AwesomeApp
But in your index.ios.js file you register other component
AppRegistry.registerComponent('Bananas', () => Bananas);
When it must be
AppRegistry.registerComponent('AwesomeApp', () => Bananas);
If your component name does match, ensure you don't have any other react-native/node process running in another terminal.
Most of the times the problem is that you have another react-native start
(i.e. React Native Packager) server running either on another terminal or another tab of TMUX (if you are using TMUX).
You need to find that process and close it, so after running react-native run-ios
for instance, it will establish a new packager server that registered for that specific application.
Just find that process using:
ps aux | grep react-native
find the process id (PID) and kill the packager process using kill
command (e.g. kill -9 [PID]
). You should find the launchPackager.command
app in macOS, not sure about the other operating systems.
Then try to run the run-ios
(or android) again. You should be able to see the new path after running the new packager server, e.g.:
Looking for JS files in
/Users/afshin/Desktop/awesome-app
My solution is change module name in "AppDelegate.m"
from
moduleName:@"AwesomeProject"
to
moduleName:@"YourNewProjectName"
Modify MainActivity
in android/app/src/main/java/com/your-package-name/MainActivity.java
like this,
@Override
protected String getMainComponentName() {
return "Bananas"; // here
}
First of all you must start your application:
react-native start
Then, you must set your application name as the first argument of registerComponent.
It works fine.
AppRegistry.registerComponent('YourProjectName', () => YourComponentName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With