diff --git a/generator/copyProjectTemplateAndReplace.js b/generator/copyProjectTemplateAndReplace.js
index 4d2725882..5adf70703 100644
--- a/generator/copyProjectTemplateAndReplace.js
+++ b/generator/copyProjectTemplateAndReplace.js
@@ -44,6 +44,8 @@ function copyProjectTemplateAndReplace(srcPath, destPath, newProjectName, option
// This also includes __tests__/index.*.js
if (fileName === 'index.ios.js') { return; }
if (fileName === 'index.android.js') { return; }
+ if (fileName === 'index.js') { return; }
+ if (fileName === 'App.js') { return; }
}
const relativeFilePath = path.relative(srcPath, absoluteSrcFilePath);
diff --git a/templates/HelloNavigation/views/MainNavigator.js b/templates/HelloNavigation/App.js
similarity index 71%
rename from templates/HelloNavigation/views/MainNavigator.js
rename to templates/HelloNavigation/App.js
index 949fb08a9..9bd3691aa 100644
--- a/templates/HelloNavigation/views/MainNavigator.js
+++ b/templates/HelloNavigation/App.js
@@ -9,13 +9,13 @@
import React, { Component } from 'react';
import { StackNavigator } from 'react-navigation';
-import HomeScreenTabNavigator from './HomeScreenTabNavigator';
-import ChatScreen from './chat/ChatScreen';
+import HomeScreenTabNavigator from './views/HomeScreenTabNavigator';
+import ChatScreen from './views/chat/ChatScreen';
/**
* Top-level navigator. Renders the application UI.
*/
-const MainNavigator = StackNavigator({
+const App = StackNavigator({
Home: {
screen: HomeScreenTabNavigator,
},
@@ -24,4 +24,4 @@ const MainNavigator = StackNavigator({
},
});
-export default MainNavigator;
+export default App;
diff --git a/templates/HelloNavigation/index.android.js b/templates/HelloNavigation/index.android.js
deleted file mode 100644
index e9ea66bf6..000000000
--- a/templates/HelloNavigation/index.android.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { AppRegistry } from 'react-native';
-
-import MainNavigator from './views/MainNavigator';
-
-AppRegistry.registerComponent('HelloWorld', () => MainNavigator);
diff --git a/templates/HelloNavigation/index.ios.js b/templates/HelloNavigation/index.ios.js
deleted file mode 100644
index e9ea66bf6..000000000
--- a/templates/HelloNavigation/index.ios.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { AppRegistry } from 'react-native';
-
-import MainNavigator from './views/MainNavigator';
-
-AppRegistry.registerComponent('HelloWorld', () => MainNavigator);
diff --git a/templates/HelloWorld/index.android.js b/templates/HelloWorld/App.js
similarity index 70%
rename from templates/HelloWorld/index.android.js
rename to templates/HelloWorld/App.js
index 71e391f53..659579088 100644
--- a/templates/HelloWorld/index.android.js
+++ b/templates/HelloWorld/App.js
@@ -6,13 +6,20 @@
import React, { Component } from 'react';
import {
- AppRegistry,
+ Platform,
StyleSheet,
Text,
View
} from 'react-native';
-export default class HelloWorld extends Component {
+const instructions = Platform.select({
+ ios: 'Press Cmd+R to reload,\n' +
+ 'Cmd+D or shake for dev menu',
+ android: 'Double tap R on your keyboard to reload,\n' +
+ 'Shake or press menu button for dev menu',
+});
+
+export default class App extends Component {
render() {
return (
@@ -20,11 +27,10 @@ export default class HelloWorld extends Component {
Welcome to React Native!
- To get started, edit index.android.js
+ To get started, edit App.js
- Double tap R on your keyboard to reload,{'\n'}
- Shake or press menu button for dev menu
+ {instructions}
);
@@ -49,5 +55,3 @@ const styles = StyleSheet.create({
marginBottom: 5,
},
});
-
-AppRegistry.registerComponent('HelloWorld', () => HelloWorld);
diff --git a/templates/HelloWorld/__tests__/index.ios.js b/templates/HelloWorld/__tests__/App.js
similarity index 81%
rename from templates/HelloWorld/__tests__/index.ios.js
rename to templates/HelloWorld/__tests__/App.js
index ba7c5b5e1..d0b9ee316 100644
--- a/templates/HelloWorld/__tests__/index.ios.js
+++ b/templates/HelloWorld/__tests__/App.js
@@ -1,12 +1,12 @@
import 'react-native';
import React from 'react';
-import Index from '../index.ios.js';
+import App from '../App';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(
-
+
);
});
diff --git a/templates/HelloWorld/__tests__/index.android.js b/templates/HelloWorld/__tests__/index.android.js
deleted file mode 100644
index b49b9087f..000000000
--- a/templates/HelloWorld/__tests__/index.android.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import 'react-native';
-import React from 'react';
-import Index from '../index.android.js';
-
-// Note: test renderer must be required after react-native.
-import renderer from 'react-test-renderer';
-
-it('renders correctly', () => {
- const tree = renderer.create(
-
- );
-});
diff --git a/templates/HelloWorld/android/app/build.gradle b/templates/HelloWorld/android/app/build.gradle
index c46fd9439..ec6f30225 100644
--- a/templates/HelloWorld/android/app/build.gradle
+++ b/templates/HelloWorld/android/app/build.gradle
@@ -72,6 +72,10 @@ import com.android.build.OutputFile
* ]
*/
+project.ext.react = [
+ entryFile: "index.js"
+]
+
apply from: "../../node_modules/react-native/react.gradle"
/**
diff --git a/templates/HelloWorld/android/app/src/main/java/com/helloworld/MainApplication.java b/templates/HelloWorld/android/app/src/main/java/com/helloworld/MainApplication.java
index f04af33c5..8b5a7f97b 100644
--- a/templates/HelloWorld/android/app/src/main/java/com/helloworld/MainApplication.java
+++ b/templates/HelloWorld/android/app/src/main/java/com/helloworld/MainApplication.java
@@ -25,6 +25,11 @@ protected List getPackages() {
new MainReactPackage()
);
}
+
+ @Override
+ protected String getJSMainModuleName() {
+ return "index";
+ }
};
@Override
diff --git a/templates/HelloWorld/index.ios.js b/templates/HelloWorld/index.ios.js
deleted file mode 100644
index ede2dc268..000000000
--- a/templates/HelloWorld/index.ios.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Sample React Native App
- * https://github.com/facebook/react-native
- * @flow
- */
-
-import React, { Component } from 'react';
-import {
- AppRegistry,
- StyleSheet,
- Text,
- View
-} from 'react-native';
-
-export default class HelloWorld extends Component {
- render() {
- return (
-
-
- Welcome to React Native!
-
-
- To get started, edit index.ios.js
-
-
- Press Cmd+R to reload,{'\n'}
- Cmd+D or shake for dev menu
-
-
- );
- }
-}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#F5FCFF',
- },
- welcome: {
- fontSize: 20,
- textAlign: 'center',
- margin: 10,
- },
- instructions: {
- textAlign: 'center',
- color: '#333333',
- marginBottom: 5,
- },
-});
-
-AppRegistry.registerComponent('HelloWorld', () => HelloWorld);
diff --git a/templates/HelloWorld/index.js b/templates/HelloWorld/index.js
new file mode 100644
index 000000000..2d090c1de
--- /dev/null
+++ b/templates/HelloWorld/index.js
@@ -0,0 +1,4 @@
+import { AppRegistry } from 'react-native';
+import App from './App';
+
+AppRegistry.registerComponent('HelloWorld', () => App);
diff --git a/templates/HelloWorld/ios/HelloWorld/AppDelegate.m b/templates/HelloWorld/ios/HelloWorld/AppDelegate.m
index cff79affc..780773801 100644
--- a/templates/HelloWorld/ios/HelloWorld/AppDelegate.m
+++ b/templates/HelloWorld/ios/HelloWorld/AppDelegate.m
@@ -18,7 +18,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
NSURL *jsCodeLocation;
- jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
+ jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"HelloWorld"