Skip to content

Commit

Permalink
Use app name from app.json for registering application
Browse files Browse the repository at this point in the history
Summary:
Currently when we change the app name in `app.json`, run `react-native eject` and then run the application, we get the following error `Application HelloWorld2 has not been registered`

<img src="https://user-images.githubusercontent.com/6805530/34646396-9a68ccd0-f38c-11e7-9a49-9f985dc20f14.png" width="33%" />

This PR picks up the app name from app.json while registering the application, which prevents the additional step for the user to change the app name while registering in the `index.js`

Tested using sinopia. The new app generated with the `react-native init HelloWorld` contains the changes made.

[CLI] [ENHANCEMENT] [index.js] - App name picked from from app.json for registering application.
Closes #17472

Differential Revision: D7788652

Pulled By: hramos

fbshipit-source-id: bf23318ae1994b06e5d5908f53818040db1ad5af
  • Loading branch information
chiraggshah authored and facebook-github-bot committed Apr 27, 2018
1 parent 7b6dd2a commit 57774a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion local-cli/templates/HelloWorld/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';

AppRegistry.registerComponent('HelloWorld', () => App);
AppRegistry.registerComponent(appName, () => App);

0 comments on commit 57774a4

Please sign in to comment.