-
Projects With Native Code Only
-
- In the particular example above, HelloWorldApp
is registered with the AppRegistry
. The AppRegistry
just tells React Native which component is the root one for the whole application. It's included in these examples so you can paste the whole thing into your index.ios.js
or index.android.js
file and get it running. If you have a project from Create React Native App, this is handled for you and it's not necessary to call AppRegistry
in your code.
-
-
-
-
## This app doesn't do very much
Good point. To make components do more interesting things, you need to [learn about Props](docs/props.html).
diff --git a/local-cli/generator/copyProjectTemplateAndReplace.js b/local-cli/generator/copyProjectTemplateAndReplace.js
index 4d272588211ce1..5adf707037ff99 100644
--- a/local-cli/generator/copyProjectTemplateAndReplace.js
+++ b/local-cli/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/local-cli/templates/HelloNavigation/views/MainNavigator.js b/local-cli/templates/HelloNavigation/App.js
similarity index 71%
rename from local-cli/templates/HelloNavigation/views/MainNavigator.js
rename to local-cli/templates/HelloNavigation/App.js
index 949fb08a972d1d..9bd3691aa4c4e6 100644
--- a/local-cli/templates/HelloNavigation/views/MainNavigator.js
+++ b/local-cli/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/local-cli/templates/HelloNavigation/index.android.js b/local-cli/templates/HelloNavigation/index.android.js
deleted file mode 100644
index e9ea66bf64ba48..00000000000000
--- a/local-cli/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/local-cli/templates/HelloNavigation/index.ios.js b/local-cli/templates/HelloNavigation/index.ios.js
deleted file mode 100644
index e9ea66bf64ba48..00000000000000
--- a/local-cli/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/local-cli/templates/HelloWorld/index.android.js b/local-cli/templates/HelloWorld/App.js
similarity index 70%
rename from local-cli/templates/HelloWorld/index.android.js
rename to local-cli/templates/HelloWorld/App.js
index 71e391f5366843..659579088c7134 100644
--- a/local-cli/templates/HelloWorld/index.android.js
+++ b/local-cli/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 (