microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
db80cd4e10b83524bc77c15018effab72cbabeb8

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

README.md

105lines · modecode

1# React Native Tools (Preview)
2[![Build Status](https://travis-ci.org/Microsoft/vscode-react-native.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-react-native)
3
4This extension provides a development environment for React Native projects.
5You can debug your code, quickly run `react-native` commands from the command palette and use IntelliSense to browse objects, functions and parameters for React Native APIs.
6
7![React Native features](images/react-features.gif)
8
9## Getting started
10
11* Install the extension in VS Code (0.10.8+)
12* Run `npm install -g react-native-cli` to install React Native CLI (0.1.10+)
13* Set up React Native (0.19+) using the steps detailed on the React Native [getting started documentation ](https://facebook.github.io/react-native/docs/getting-started.html)
14* Open your React Native project root directory in VS Code.
15* (Optional) [Enable IntelliSense](#enabling-intellisense) support (experimental)
16
17## Debugging
18
19### Setup debug environment
20
21Click the debugging icon ![Choose React Native debugger](images/debug-view-icon.png) in the View bar, and then click the configure gear icon ![Configure-gear](images/configure-gear-icon.png) to choose the React Native debug environment.
22
23![Choose React Native debugger](images/choose-debugger.png)
24
25VS Code will generate a `launch.json` in your project with some default configurations such as shown below.
26
27![React Native launch configuration file](images/launch-config.png)
28
29You can modify these configurations or add new ones to the list. You can use other fields in these configurations as well.
30
31For example, you can modify the `target` field to specify the simulator you want to target for iOS debugging.
32
33### Start debug session
34To start the debug session, select a configuration from the Configuration dropdown, and then click the start button ![Configure-gear](images/debug-icon.png) (or press F5).
35
36![React Native launch targets](images/debug-targets.png)
37
38You can debug your app on an Android emulator, Android device or iOS simulator. This extension provides [experiemental support](#debugging-on-ios-device) for iOS devices.
39
40More information about debugging using VS Code can be found in this [guide](https://code.visualstudio.com/docs/editor/debugging)
41
42#### Debugging on iOS device
43Debugging on iOS device would require following manual steps
44* Change the `jsCodeLocation` IP in your app using the steps detailed [here](https://facebook.github.io/react-native/docs/running-on-device-ios.html#accessing-development-server-from-device)
45* Choose **Debug iOS** configuration from the Configuration dropdown and press F5.
46* Shake the device to open development menu and select "Debug in Chrome"
47
48## Using React Native commands in the Command Palette
49
50In the Command Palette, type ```React Native``` and choose a command.
51
52![React Native commands](images/command-palette.png)
53
54The **Run Android** command triggers ```react-native run-android``` and starts your app for android.
55
56The **Run iOS** command similarly triggers ```react-native run-ios``` and starts your app in iOS simulator (iPhone 6).
57
58The **Packager** commands allow you to start/stop the [**React-packager**](https://github.com/facebook/react-native/tree/master/packager).
59
60## Using IntelliSense
61
62IntelliSense helps you discover objects, functions, and parameters in React Native.
63
64![IntelliSense](images/intellisense.png)
65
66### Enabling IntelliSense
67React Native IntelliSense depends on experimental features to support JSX in VS Code.
68To enable these experimental features, you will see the following prompt immediately after opening a React Native project.
69
70![IntelliSense prompt](images/intellisense-prompt.png)
71
72This is a one-time prompt and will enable JSX support. You will need to restart VS Code once for changes to take effect.
73
74You can verify that you have Salsa enabled and you have an installed TypeScript version that supports Salsa by checking the status indicator in the Status Bar. This shows that all is OK
75
76![Salsa Enabled](https://code.visualstudio.com/images/January_salsa-status.png)
77
78Once you have enabled IntelliSense by following the above steps, you can start typing in the code editor to see the objects, functions, and parameters of your React Native libraries and your own code.
79
80Here is what happens behind the scenes to enable JSX support
81
821. The environment variable VSCODE_TSJS=1 is set to enable [Salsa](https://github.com/Microsoft/TypeScript/issues/4789)
832. Salsa requires TypeScript 1.8 but the final 1.8 release isn't available yet. Extension installs `typescript@next` in `~/.vscode`
843. A settings.json file is created in the .vscode directory with typescript.tsdk pointing to the typescript@next install location.
854. A tsconfig.json file is created in the project root with `allowJs: true` to allow TypeScript to process JavaScript files.
865. Typings for React Native are copied into the .vscode directory.
87
88## Known Issues
89
90Here is the list of common known issues you may experience while using the extension
91
92Issue | Description
93------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------
94Debugger doesn't stop at breakpoints | The debugger only works if the packager is started by VS Code. Stop the packager if it is already running outside VSCode.
95'adb: command not found' | If you receive an error `adb: command not found`, you need to update your path variable to include the location of your *ADB* executable.The *ADB* executable file is located in a subdirectory along with your other Android SDK files.
96Targeting iPhone 6 doesn't work | There is a known issue [#5850](https://github.com/facebook/react-native/issues/5850) while running an app targeting iPhone 6
97
98Click [here](https://github.com/Microsoft/vscode-react-native/issues?q=is%3Aopen+is%3Aissue+label%3Apreview-known-issues) for the complete list of known issues.
99
100## Disable telemetry reporting
101VS Code React Native extension collects usage data and sends it to Microsoft to help improve our products and services. Read our [privacy statement](https://www.visualstudio.com/en-us/dn948229) to learn more.
102
103If you don’t wish to send usage data to Microsoft, please follow the instructions below to disable its collection.
104
105* Edit VSCodeTelemetrySettings.json file at ~/.vscode-react-native and add `optIn:false`.