mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
216 lines
30 KiB
HTML
216 lines
30 KiB
HTML
<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>Getting Started – React Native | A framework for building native apps using React</title><meta name="viewport" content="width=device-width"><meta property="og:title" content="Getting Started – React Native | A framework for building native apps using React"><meta property="og:type" content="website"><meta property="og:url" content="http://facebook.github.io/react-native/index.html"><meta property="og:image" content="http://facebook.github.io/react-native/img/opengraph.png?2"><meta property="og:description" content="A framework for building native apps using React"><base href="/react-native/"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css"><link rel="shortcut icon" href="img/favicon.png?2"><link rel="stylesheet" href="css/react-native.css"><script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script><script type="text/javascript">try{Typekit.load();}catch(e){}</script></head><body><div class="container"><div class="nav-main"><div class="wrap"><a class="nav-home" href=""><img src="img/header_logo.png">React Native</a><a class="nav-version" href="/react-native/versions.html">0.31</a><div class="nav-site-wrapper"><ul class="nav-site nav-site-internal"><li><a href="docs/getting-started.html" class="active" data-target=".nav-docs">Docs</a></li><li><a href="support.html" class="">Support</a></li><li><a href="showcase.html" class="">Showcase</a></li><li><a href="blog/" class="">Blog</a></li></ul><div class="algolia-search-wrapper"><input id="algolia-doc-search" tabindex="0" type="text" placeholder="Search docs..."></div><ul class="nav-site nav-site-external"><li><a href="https://github.com/facebook/react-native" class="">GitHub</a></li><li><a href="http://facebook.github.io/react" class="">React</a></li></ul></div></div></div><section class="content wrap documentationContent"><div class="nav-docs"><div class="nav-docs-viewport"><div class="nav-docs-section"><h3>The Basics</h3><ul><li><a style="margin-left:0;" class="active" href="docs/getting-started.html">Getting Started</a></li><li><a style="margin-left:0;" class="" href="docs/tutorial.html">Tutorial</a></li><li><a style="margin-left:0;" class="" href="docs/props.html">Props</a></li><li><a style="margin-left:0;" class="" href="docs/state.html">State</a></li><li><a style="margin-left:0;" class="" href="docs/style.html">Style</a></li><li><a style="margin-left:0;" class="" href="docs/height-and-width.html">Height and Width</a></li><li><a style="margin-left:0;" class="" href="docs/flexbox.html">Layout with Flexbox</a></li><li><a style="margin-left:0;" class="" href="docs/handling-text-input.html">Handling Text Input</a></li><li><a style="margin-left:0;" class="" href="docs/using-a-scrollview.html">Using a ScrollView</a></li><li><a style="margin-left:0;" class="" href="docs/using-a-listview.html">Using a ListView</a></li><li><a style="margin-left:0;" class="" href="docs/network.html">Networking</a></li><li><a style="margin-left:0;" class="" href="docs/using-navigators.html">Using Navigators</a></li><li><a style="margin-left:0;" class="" href="docs/more-resources.html">More Resources</a></li></ul></div><div class="nav-docs-section"><h3>Guides</h3><ul><li><a style="margin-left:0;" class="" href="docs/integration-with-existing-apps.html">Integration With Existing Apps</a></li><li><a style="margin-left:0;" class="" href="docs/colors.html">Colors</a></li><li><a style="margin-left:0;" class="" href="docs/images.html">Images</a></li><li><a style="margin-left:0;" class="" href="docs/handling-touches.html">Handling Touches</a></li><li><a style="margin-left:0;" class="" href="docs/animations.html">Animations</a></li><li><a style="margin-left:0;" class="" href="docs/accessibility.html">Accessibility</a></li><li><a style="margin-left:0;" class="" href="docs/timers.html">Timers</a></li><li><a style="margin-left:0;" class="" href="docs/direct-manipulation.html">Direct Manipulation</a></li><li><a style="margin-left:0;" class="" href="docs/debugging.html">Debugging</a></li><li><a style="margin-left:0;" class="" href="docs/testing.html">Testing</a></li><li><a style="margin-left:0;" class="" href="docs/javascript-environment.html">JavaScript Environment</a></li><li><a style="margin-left:0;" class="" href="docs/navigation.html">Navigation</a></li><li><a style="margin-left:0;" class="" href="docs/performance.html">Performance</a></li><li><a style="margin-left:0;" class="" href="docs/upgrading.html">Upgrading</a></li><li><a style="margin-left:0;" class="" href="docs/platform-specific-code.html">Platform Specific Code</a></li><li><a style="margin-left:0;" class="" href="docs/gesture-responder-system.html">Gesture Responder System</a></li></ul></div><div class="nav-docs-section"><h3>Guides (iOS)</h3><ul><li><a style="margin-left:0;" class="" href="docs/native-modules-ios.html">Native Modules</a></li><li><a style="margin-left:0;" class="" href="docs/native-components-ios.html">Native UI Components</a></li><li><a style="margin-left:0;" class="" href="docs/linking-libraries-ios.html">Linking Libraries</a></li><li><a style="margin-left:0;" class="" href="docs/running-on-device-ios.html">Running On Device</a></li><li><a style="margin-left:0;" class="" href="docs/running-on-simulator-ios.html">Running On Simulator</a></li><li><a style="margin-left:0;" class="" href="docs/communication-ios.html">Communication between native and React Native</a></li></ul></div><div class="nav-docs-section"><h3>Guides (Android)</h3><ul><li><a style="margin-left:0;" class="" href="docs/native-modules-android.html">Native Modules</a></li><li><a style="margin-left:0;" class="" href="docs/native-components-android.html">Native UI Components</a></li><li><a style="margin-left:0;" class="" href="docs/running-on-device-android.html">Running On Device</a></li><li><a style="margin-left:0;" class="" href="docs/signed-apk-android.html">Generating Signed APK</a></li><li><a style="margin-left:0;" class="" href="docs/android-ui-performance.html">Profiling Android UI Performance</a></li><li><a style="margin-left:0;" class="" href="docs/android-building-from-source.html">Building React Native from source</a></li></ul></div><div class="nav-docs-section"><h3>components</h3><ul><li><a style="margin-left:0;" class="" href="docs/activityindicator.html">ActivityIndicator</a></li><li><a style="margin-left:0;" class="" href="docs/activityindicatorios.html">ActivityIndicatorIOS</a></li><li><a style="margin-left:0;" class="" href="docs/datepickerios.html">DatePickerIOS</a></li><li><a style="margin-left:0;" class="" href="docs/drawerlayoutandroid.html">DrawerLayoutAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/image.html">Image</a></li><li><a style="margin-left:0;" class="" href="docs/listview.html">ListView</a></li><li><a style="margin-left:0;" class="" href="docs/mapview.html">MapView</a></li><li><a style="margin-left:0;" class="" href="docs/modal.html">Modal</a></li><li><a style="margin-left:0;" class="" href="docs/navigator.html">Navigator</a></li><li><a style="margin-left:0;" class="" href="docs/navigatorios.html">NavigatorIOS</a></li><li><a style="margin-left:0;" class="" href="docs/picker.html">Picker</a></li><li><a style="margin-left:0;" class="" href="docs/pickerios.html">PickerIOS</a></li><li><a style="margin-left:0;" class="" href="docs/progressbarandroid.html">ProgressBarAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/progressviewios.html">ProgressViewIOS</a></li><li><a style="margin-left:0;" class="" href="docs/refreshcontrol.html">RefreshControl</a></li><li><a style="margin-left:0;" class="" href="docs/scrollview.html">ScrollView</a></li><li><a style="margin-left:0;" class="" href="docs/segmentedcontrolios.html">SegmentedControlIOS</a></li><li><a style="margin-left:0;" class="" href="docs/slider.html">Slider</a></li><li><a style="margin-left:0;" class="" href="docs/sliderios.html">SliderIOS</a></li><li><a style="margin-left:0;" class="" href="docs/statusbar.html">StatusBar</a></li><li><a style="margin-left:0;" class="" href="docs/snapshotviewios.html">SnapshotViewIOS</a></li><li><a style="margin-left:0;" class="" href="docs/switch.html">Switch</a></li><li><a style="margin-left:0;" class="" href="docs/switchandroid.html">SwitchAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/switchios.html">SwitchIOS</a></li><li><a style="margin-left:0;" class="" href="docs/tabbarios.html">TabBarIOS</a></li><li><a style="margin-left:0;" class="" href="docs/tabbarios-item.html">TabBarIOS.Item</a></li><li><a style="margin-left:0;" class="" href="docs/text.html">Text</a></li><li><a style="margin-left:0;" class="" href="docs/textinput.html">TextInput</a></li><li><a style="margin-left:0;" class="" href="docs/toolbarandroid.html">ToolbarAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/touchablehighlight.html">TouchableHighlight</a></li><li><a style="margin-left:0;" class="" href="docs/touchablenativefeedback.html">TouchableNativeFeedback</a></li><li><a style="margin-left:0;" class="" href="docs/touchableopacity.html">TouchableOpacity</a></li><li><a style="margin-left:0;" class="" href="docs/touchablewithoutfeedback.html">TouchableWithoutFeedback</a></li><li><a style="margin-left:0;" class="" href="docs/view.html">View</a></li><li><a style="margin-left:0;" class="" href="docs/viewpagerandroid.html">ViewPagerAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/webview.html">WebView</a></li></ul></div><div class="nav-docs-section"><h3>apis</h3><ul><li><a style="margin-left:0;" class="" href="docs/actionsheetios.html">ActionSheetIOS</a></li><li><a style="margin-left:0;" class="" href="docs/adsupportios.html">AdSupportIOS</a></li><li><a style="margin-left:0;" class="" href="docs/alert.html">Alert</a></li><li><a style="margin-left:0;" class="" href="docs/alertios.html">AlertIOS</a></li><li><a style="margin-left:0;" class="" href="docs/animated.html">Animated</a></li><li><a style="margin-left:0;" class="" href="docs/appregistry.html">AppRegistry</a></li><li><a style="margin-left:0;" class="" href="docs/appstate.html">AppState</a></li><li><a style="margin-left:0;" class="" href="docs/asyncstorage.html">AsyncStorage</a></li><li><a style="margin-left:0;" class="" href="docs/backandroid.html">BackAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/cameraroll.html">CameraRoll</a></li><li><a style="margin-left:0;" class="" href="docs/clipboard.html">Clipboard</a></li><li><a style="margin-left:0;" class="" href="docs/datepickerandroid.html">DatePickerAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/dimensions.html">Dimensions</a></li><li><a style="margin-left:0;" class="" href="docs/easing.html">Easing</a></li><li><a style="margin-left:0;" class="" href="docs/geolocation.html">Geolocation</a></li><li><a style="margin-left:0;" class="" href="docs/imageeditor.html">ImageEditor</a></li><li><a style="margin-left:0;" class="" href="docs/imagepickerios.html">ImagePickerIOS</a></li><li><a style="margin-left:0;" class="" href="docs/imagestore.html">ImageStore</a></li><li><a style="margin-left:0;" class="" href="docs/intentandroid.html">IntentAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/interactionmanager.html">InteractionManager</a></li><li><a style="margin-left:0;" class="" href="docs/layoutanimation.html">LayoutAnimation</a></li><li><a style="margin-left:0;" class="" href="docs/linking.html">Linking</a></li><li><a style="margin-left:0;" class="" href="docs/nativemethodsmixin.html">NativeMethodsMixin</a></li><li><a style="margin-left:0;" class="" href="docs/nativemodules.html">NativeModules</a></li><li><a style="margin-left:0;" class="" href="docs/netinfo.html">NetInfo</a></li><li><a style="margin-left:0;" class="" href="docs/panresponder.html">PanResponder</a></li><li><a style="margin-left:0;" class="" href="docs/pixelratio.html">PixelRatio</a></li><li><a style="margin-left:0;" class="" href="docs/pushnotificationios.html">PushNotificationIOS</a></li><li><a style="margin-left:0;" class="" href="docs/settings.html">Settings</a></li><li><a style="margin-left:0;" class="" href="docs/statusbarios.html">StatusBarIOS</a></li><li><a style="margin-left:0;" class="" href="docs/stylesheet.html">StyleSheet</a></li><li><a style="margin-left:0;" class="" href="docs/systrace.html">Systrace</a></li><li><a style="margin-left:0;" class="" href="docs/timepickerandroid.html">TimePickerAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/toastandroid.html">ToastAndroid</a></li><li><a style="margin-left:0;" class="" href="docs/vibration.html">Vibration</a></li><li><a style="margin-left:0;" class="" href="docs/vibrationios.html">VibrationIOS</a></li><li><a style="margin-left:0;" class="" href="docs/layout-props.html">Layout Props</a></li><li><a style="margin-left:0;" class="" href="docs/shadow-props.html">Shadow Props</a></li></ul></div></div></div><div class="inner-content"><a id="content"></a><table width="100%"><tbody><tr><td><h1><a class="anchor" name="getting-started"></a>Getting Started <a class="hash-link" href="docs/getting-started.html#getting-started">#</a></h1></td><td style="text-align:right;"><a target="_blank" href="https://github.com/facebook/react-native/blob/0.31-stable/docs/GettingStarted.md">Edit on GitHub</a></td></tr></tbody></table><div><p>Welcome to React Native! This page will help you install React Native on
|
||
your system, so that you can build apps with it right away. If you already
|
||
have React Native installed, you can skip ahead to the
|
||
<a href="/react-native/docs/tutorial.html" target="">Tutorial</a>.</p><p>The instructions are a bit different depending on your development operating system, and whether you want to start developing for iOS or Android. If you
|
||
want to develop for both iOS and Android, that's fine - you just have to pick
|
||
one to start with, since the setup is a bit different.</p><span><div class="toggler">
|
||
<style>
|
||
.toggler a {
|
||
display: inline-block;
|
||
padding: 10px 5px;
|
||
margin: 2px;
|
||
border: 1px solid #05A5D1;
|
||
border-radius: 3px;
|
||
text-decoration: none !important;
|
||
}
|
||
.display-os-mac .toggler .button-mac,
|
||
.display-os-linux .toggler .button-linux,
|
||
.display-os-windows .toggler .button-windows,
|
||
.display-platform-ios .toggler .button-ios,
|
||
.display-platform-android .toggler .button-android {
|
||
background-color: #05A5D1;
|
||
color: white;
|
||
}
|
||
block { display: none; }
|
||
.display-platform-ios.display-os-mac .ios.mac,
|
||
.display-platform-ios.display-os-linux .ios.linux,
|
||
.display-platform-ios.display-os-windows .ios.windows,
|
||
.display-platform-android.display-os-mac .android.mac,
|
||
.display-platform-android.display-os-linux .android.linux,
|
||
.display-platform-android.display-os-windows .android.windows {
|
||
display: block;
|
||
}</style>
|
||
<span>Mobile OS:</span>
|
||
<a href="javascript:void(0);" class="button-ios" onclick="display('platform', 'ios')">iOS</a>
|
||
<a href="javascript:void(0);" class="button-android" onclick="display('platform', 'android')">Android</a>
|
||
<span>Development OS:</span>
|
||
<a href="javascript:void(0);" class="button-mac" onclick="display('os', 'mac')">Mac</a>
|
||
<a href="javascript:void(0);" class="button-linux" onclick="display('os', 'linux')">Linux</a>
|
||
<a href="javascript:void(0);" class="button-windows" onclick="display('os', 'windows')">Windows</a>
|
||
</div>
|
||
|
||
</span><span><!-- ######### LINUX AND WINDOWS for iOS ##################### -->
|
||
|
||
</span><span><block class="linux windows ios" />
|
||
|
||
</span><h2><a class="anchor" name="unsupported"></a>Unsupported <a class="hash-link" href="docs/getting-started.html#unsupported">#</a></h2><span><div>Unfortunately, Apple only lets you develop for iOS on a Mac. If you want to build an iOS app but you don't have a Mac yet, you can try starting with the <a href="" onclick="display('platform', 'android')">Android</a> instructions instead.</div>
|
||
|
||
</span><span><center><img src="img/react-native-sorry-not-supported.png" width="150"></img></center>
|
||
|
||
</span><span><!-- ######### MAC for iOS ##################### -->
|
||
|
||
</span><span><block class="mac ios" />
|
||
|
||
</span><h2><a class="anchor" name="dependencies-for-mac-ios"></a>Dependencies for Mac + iOS <a class="hash-link" href="docs/getting-started.html#dependencies-for-mac-ios">#</a></h2><p>You will need Xcode, node.js, the React Native command line tools, and Watchman.</p><span><block class="mac android" />
|
||
|
||
</span><h2><a class="anchor" name="dependencies-for-mac-android"></a>Dependencies for Mac + Android <a class="hash-link" href="docs/getting-started.html#dependencies-for-mac-android">#</a></h2><p>You will need Android Studio, node.js, the React Native command line tools, and Watchman.</p><span><block class="mac ios android" />
|
||
|
||
</span><p>We recommend installing node and watchman via <a href="http://brew.sh/" target="_blank">Homebrew</a>.</p><div class="prism language-javascript">brew install node
|
||
brew install watchman</div><p>Node comes with npm, which lets you install the React Native command line interface.</p><div class="prism language-javascript">npm install <span class="token operator">-</span>g react<span class="token operator">-</span>native<span class="token operator">-</span>cli</div><p>If you get a permission error, try with sudo: <code>sudo npm install -g react-native-cli</code>.</p><span><block class="mac ios" />
|
||
|
||
</span><p>The easiest way to install Xcode is via the <a href="https://itunes.apple.com/us/app/xcode/id497799835?mt=12" target="_blank">Mac App Store</a>.</p><span><block class="mac android" />
|
||
|
||
</span><p>Download and install <a href="https://developer.android.com/studio/install.html" target="_blank">Android Studio</a>.</p><p>If you plan to make changes in Java code, we recommend <a href="https://docs.gradle.org/2.9/userguide/gradle_daemon.html" target="_blank">Gradle Daemon</a> which speeds up the build.</p><span><!-- ######### LINUX and WINDOWS for ANDROID ##################### -->
|
||
|
||
</span><span><block class="linux android" />
|
||
|
||
</span><h2><a class="anchor" name="dependencies-for-linux-android"></a>Dependencies for Linux + Android <a class="hash-link" href="docs/getting-started.html#dependencies-for-linux-android">#</a></h2><span><block class="windows android" />
|
||
|
||
</span><h2><a class="anchor" name="dependencies-for-windows-android"></a>Dependencies for Windows + Android <a class="hash-link" href="docs/getting-started.html#dependencies-for-windows-android">#</a></h2><span><block class="linux windows android" />
|
||
|
||
</span><p>You will need node.js, the React Native command line tools, Watchman, and Android Studio.</p><span><block class="linux android" />
|
||
|
||
</span><p>Follow the <a href="https://nodejs.org/en/download/package-manager/" target="_blank">installation instructions for your Linux distribution</a> to install Node.js 4 or newer.</p><span><block class='windows android' />
|
||
|
||
</span><p>We recommend installing node.js and Python2 via <a href="https://chocolatey.org" target="_blank">Chocolatey</a>, a popular package manager for Windows. Open a Command Prompt as Administrator, then run:</p><div class="prism language-javascript">choco install nodejs<span class="token punctuation">.</span>install
|
||
choco install python2</div><span><block class="windows linux android" />
|
||
|
||
</span><p>Node comes with npm, which lets you install the React Native command line interface.</p><div class="prism language-javascript">npm install <span class="token operator">-</span>g react<span class="token operator">-</span>native<span class="token operator">-</span>cli</div><span><block class="windows linux android" />
|
||
|
||
</span><p>Download and install <a href="https://developer.android.com/studio/install.html" target="_blank">Android Studio</a>.</p><span><block class="linux android" />
|
||
|
||
</span><p><a href="https://facebook.github.io/watchman" target="_blank">Watchman</a> is a tool by Facebook for watching changes in the filesystem. Installing it should
|
||
improve performance, but you can also try not installing it, if the installation process is too annoying. You can follow the <a href="https://facebook.github.io/watchman/docs/install.html#installing-from-source" target="_blank">Watchman installation guide</a> to compile and install from source.</p><span><block class="windows linux android" />
|
||
|
||
</span><p>If you plan to make changes in Java code, we recommend <a href="https://docs.gradle.org/2.9/userguide/gradle_daemon.html" target="_blank">Gradle Daemon</a> which speeds up the build.</p><span><block class="mac ios android" />
|
||
|
||
</span><h2><a class="anchor" name="testing-your-react-native-installation"></a>Testing your React Native Installation <a class="hash-link" href="docs/getting-started.html#testing-your-react-native-installation">#</a></h2><span><block class="mac ios" />
|
||
|
||
</span><p>Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run <code>react-native run-ios</code> inside the newly created folder.</p><div class="prism language-javascript">react<span class="token operator">-</span>native init AwesomeProject
|
||
cd AwesomeProject
|
||
react<span class="token operator">-</span>native run<span class="token operator">-</span>ios</div><p>You should see your new app running in the iOS Simulator shortly. <code>react-native run-ios</code> is just one way to run your app - you can also run it directly from within Xcode or Nuclide.</p><span><block class="mac android" />
|
||
|
||
</span><p>Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run <code>react-native run-android</code> inside the newly created folder.</p><div class="prism language-javascript">react<span class="token operator">-</span>native init AwesomeProject
|
||
cd AwesomeProject
|
||
react<span class="token operator">-</span>native run<span class="token operator">-</span>android</div><p>If everything is set up correctly, you should see your new app running in your Android emulator shortly. <code>react-native run-android</code> is just one way to run your app - you can also run it directly from within Android Studio or Nuclide.</p><span><block class="mac ios android" />
|
||
|
||
</span><h3><a class="anchor" name="modifying-your-app"></a>Modifying your app <a class="hash-link" href="docs/getting-started.html#modifying-your-app">#</a></h3><p>Now that you have successfully run the app, let's modify it.</p><span><block class="mac ios" />
|
||
|
||
</span><ul><li>Open <code>index.ios.js</code> in your text editor of choice and edit some lines.</li><li>Hit <code>Command⌘ + R</code> in your iOS Simulator to reload the app and see your change!</li></ul><span><block class="mac android" />
|
||
|
||
</span><ul><li>Open <code>index.android.js</code> in your text editor of choice and edit some lines.</li><li>Press the <code>R</code> key twice or select <code>Reload</code> from the Developer Menu to see your change!</li></ul><span><block class="mac ios android" />
|
||
|
||
</span><h3><a class="anchor" name="that-s-it"></a>That's it! <a class="hash-link" href="docs/getting-started.html#that-s-it">#</a></h3><p>Congratulations! You've successfully run and modified your first React Native app.</p><span><center><img src="img/react-native-congratulations.png" width="150"></img></center>
|
||
|
||
</span><span><block class="windows linux android" />
|
||
|
||
</span><h2><a class="anchor" name="testing-your-react-native-installation"></a>Testing your React Native Installation <a class="hash-link" href="docs/getting-started.html#testing-your-react-native-installation">#</a></h2><p>Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run <code>react-native run-android</code> inside the newly created folder.</p><div class="prism language-javascript">react<span class="token operator">-</span>native init AwesomeProject
|
||
cd AwesomeProject
|
||
react<span class="token operator">-</span>native run<span class="token operator">-</span>android</div><p>If everything is set up correctly, you should see your new app running in your Android emulator shortly.</p><blockquote><p>A common issue is that the packager is not started automatically when you run
|
||
<code>react-native run-android</code>. You can start it manually using <code>react-native start</code>.</p></blockquote><span><block class="windows android" />
|
||
|
||
</span><blockquote><p>If you hit a <code>ERROR Watcher took too long to load</code> on Windows, try increasing the timeout in <a href="https://github.com/facebook/react-native/blob/5fa33f3d07f8595a188f6fe04d6168a6ede1e721/packager/react-packager/src/DependencyResolver/FileWatcher/index.js#L16" target="_blank">this file</a> (under your <code>node_modules/react-native/</code>).</p></blockquote><span><block class="windows linux android" />
|
||
|
||
</span><h3><a class="anchor" name="modifying-your-app"></a>Modifying your app <a class="hash-link" href="docs/getting-started.html#modifying-your-app">#</a></h3><p>Now that you have successfully run the app, let's modify it.</p><ul><li>Open <code>index.android.js</code> in your text editor of choice and edit some lines.</li><li>Press the <code>R</code> key twice or select <code>Reload</code> from the Developer Menu to see your change!</li></ul><h3><a class="anchor" name="that-s-it"></a>That's it! <a class="hash-link" href="docs/getting-started.html#that-s-it">#</a></h3><p>Congratulations! You've successfully run and modified a React Native app.</p><span><center><img src="img/react-native-congratulations.png" width="150"></img></center>
|
||
|
||
</span><span><block class="mac windows linux ios android" />
|
||
|
||
</span><h2><a class="anchor" name="now-what"></a>Now What? <a class="hash-link" href="docs/getting-started.html#now-what">#</a></h2><ul><li><p>If you want to add this new React Native code to an existing application, check out the <a href="docs/integration-with-existing-apps.html" target="_blank">Integration guide</a>.</p></li><li><p>If you can't get this to work, see the <a href="docs/troubleshooting.html#content" target="_blank">Troubleshooting</a> page.</p></li><li><p>If you're curious to learn more about React Native, continue on
|
||
to the <a href="docs/tutorial.html" target="_blank">Tutorial</a>.</p></li></ul><span><script>
|
||
// Convert <div>...<span><block /></span>...</div>
|
||
// Into <div>...<block />...</div>
|
||
var blocks = document.getElementsByTagName('block');
|
||
for (var i = 0; i < blocks.length; ++i) {
|
||
var block = blocks[i];
|
||
var span = blocks[i].parentNode;
|
||
var container = span.parentNode;
|
||
container.insertBefore(block, span);
|
||
container.removeChild(span);
|
||
}
|
||
// Convert <div>...<block />content<block />...</div>
|
||
// Into <div>...<block>content</block><block />...</div>
|
||
blocks = document.getElementsByTagName('block');
|
||
for (var i = 0; i < blocks.length; ++i) {
|
||
var block = blocks[i];
|
||
while (block.nextSibling && block.nextSibling.tagName !== 'BLOCK') {
|
||
block.appendChild(block.nextSibling);
|
||
}
|
||
}
|
||
function display(type, value) {
|
||
var container = document.getElementsByTagName('block')[0].parentNode;
|
||
container.className = 'display-' + type + '-' + value + ' ' +
|
||
container.className.replace(RegExp('display-' + type + '-[a-z]+ ?'), '');
|
||
}
|
||
|
||
// If we are coming to the page with a hash in it (i.e. from a search, for example), try to get
|
||
// us as close as possible to the correct platform and dev os using the hashtag and block walk up.
|
||
var foundHash = false;
|
||
if (window.location.hash !== '' && window.location.hash !== 'content') { // content is default
|
||
var hashLinks = document.querySelectorAll('a.hash-link');
|
||
for (var i = 0; i < hashLinks.length && !foundHash; ++i) {
|
||
if (hashLinks[i].hash === window.location.hash) {
|
||
var parent = hashLinks[i].parentElement;
|
||
while (parent) {
|
||
if (parent.tagName === 'BLOCK') {
|
||
var devOS = null;
|
||
var targetPlatform = null;
|
||
// Could be more than one target os and dev platform, but just choose some sort of order
|
||
// of priority here.
|
||
|
||
// Dev OS
|
||
if (parent.className.indexOf('mac') > -1) {
|
||
devOS = 'mac';
|
||
} else if (parent.className.indexOf('linux') > -1) {
|
||
devOS = 'linux';
|
||
} else if (parent.className.indexOf('windows') > -1) {
|
||
devOS = 'windows';
|
||
} else {
|
||
break; // assume we don't have anything.
|
||
}
|
||
|
||
// Target Platform
|
||
if (parent.className.indexOf('ios') > -1) {
|
||
targetPlatform = 'ios';
|
||
} else if (parent.className.indexOf('android') > -1) {
|
||
targetPlatform = 'android';
|
||
} else {
|
||
break; // assume we don't have anything.
|
||
}
|
||
// We would have broken out if both targetPlatform and devOS hadn't been filled.
|
||
display('os', devOS);
|
||
display('platform', targetPlatform);
|
||
foundHash = true;
|
||
break;
|
||
}
|
||
parent = parent.parentElement;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// Do the default if there is no matching hash
|
||
if (!foundHash) {
|
||
var isMac = navigator.platform === 'MacIntel';
|
||
var isWindows = navigator.platform === 'Win32';
|
||
display('os', isMac ? 'mac' : (isWindows ? 'windows' : 'linux'));
|
||
display('platform', isMac ? 'ios' : 'android');
|
||
}
|
||
</script>
|
||
</span></div><div class="docs-prevnext"><a class="docs-next" href="docs/tutorial.html#content">Next →</a></div><div class="survey"><div class="survey-image"></div><p>Recently, we have been working hard to make the documentation better based on your feedback. Your responses to this yes/no style survey will help us gauge whether we moved in the right direction with the improvements. Thank you!</p><center><a class="button" href="https://www.facebook.com/survey?oid=516954245168428">Take Survey</a></center></div></div></section><footer class="wrap"><div class="center">© 2016 Facebook Inc.</div></footer></div><div id="fb-root"></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>
|
||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||
ga('create', 'UA-41298772-2', 'facebook.github.io');
|
||
ga('send', 'pageview');
|
||
|
||
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)
|
||
){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";
|
||
fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
|
||
|
||
docsearch({
|
||
apiKey: '2c98749b4a1e588efec53b2acec13025',
|
||
indexName: 'react-native-versions',
|
||
inputSelector: '#algolia-doc-search',
|
||
algoliaOptions: { facetFilters: [ "tags:0.31" ], hitsPerPage: 5 }
|
||
});
|
||
</script><script src="js/scripts.js"></script></body></html> |