Accessing the In-App Developer Menu
- React Debugger Chrome
- React Native Debugger Expo
- React Native Debugger Open
- React Native Debugger
- React Native Debugger Download
- React Native Debugger Mac Download Version
Sep 15, 2020. React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces. Use a little—or a lot. You can use React Native today in your existing Android and iOS projects or you can create a whole new app from scratch. Oct 28, 2019. Feb 26, 2018.
You can access the developer menu by shaking your device or by selecting 'Shake Gesture' inside the Hardware menu in the iOS Simulator. You can also use the
⌘D
keyboard shortcut when your app is running in the iOS Simulator, or ⌘M
when running in an Android emulator on Mac OS and Ctrl+M
on Windows and Linux. Alternatively for Android, you can run the command adb shell input keyevent 82
to open the dev menu (82 being the Menu key code).The Developer Menu is disabled in release (production) builds.
Enabling Fast Refresh
Fast Refresh is a React Native feature that allows you to get near-instant feedback for changes in your React components. While debugging, it can help to have Fast Refresh enabled. Fast Refresh is enabled by default, and you can toggle 'Enable Fast Refresh' in the React Native developer menu. When enabled, most of your edits should be visible within a second or two.
Enabling Keyboard Shortcuts
React Native supports a few keyboard shortcuts in the iOS Simulator. They are described below. To enable them, open the Hardware menu, select Keyboard, and make sure that 'Connect Hardware Keyboard' is checked.
LogBox
Errors and warnings in development builds are displayed in LogBox inside your app.
LogBox is automatically disabled in release (production) builds.
Console Errors and Warnings
Console errors and warnings are displayed as on-screen notifications with a red or yellow badge, and the number of errors or warning in the console respectively. To view a console error or warnings, tap the notification to view the full screen information about the log and to paginiate through all of the logs in the console.
These notifications can be hidden using
LogBox.ignoreAllLogs()
. This is useful when giving product demos, for example. Additionally, notifications can be hidden on a per-log basis via LogBox.ignoreLogs()
. This is useful when there's a noisy warning that cannot be fixed, like those in a third-party dependency.Ignore logs as a last resort and create a task to fix any logs that are ignored.
Unhandled Errors
Unhanded JavaScript errors such as
undefined is not a function
will automatically open a full screen LogBox error with the source of the error. These errors are dismissable and minimizable so that you can see the state of your app when these errors occur, but should always be addressed.Syntax Errors
Syntax errors will automatically open a full screen LogBox error with the source of the syntax error. This error is not dismissable because it represents invalid JavaScript execution that must be fixed before continuing with your app. To dismiss these errors, fix the syntax error and either save to automatically dismiss (with Fast Refresh enabled) or cmd+r to reload (with Fast Refresh disabled).
Chrome Developer Tools
To debug the JavaScript code in Chrome, select 'Debug JS Remotely' from the Developer Menu. This will open a new tab at http://localhost:8081/debugger-ui.
Select
Tools → Developer Tools
from the Chrome Menu to open the Developer Tools. You may also access the DevTools using keyboard shortcuts (⌘⌥I
on macOS, Ctrl
Shift
I
on Windows). You may also want to enable Pause On Caught Exceptions for a better debugging experience.Note: the React Developer Tools Chrome extension does not work with React Native, but you can use its standalone version instead. Read this section to learn how.
Debugging using a custom JavaScript debugger
To use a custom JavaScript debugger in place of Chrome Developer Tools, set the
REACT_DEBUGGER
environment variable to a command that will start your custom debugger. You can then select 'Debug JS Remotely' from the Developer Menu to start debugging.The debugger will receive a list of all project roots, separated by a space. For example, if you set
REACT_DEBUGGER='node /path/to/launchDebugger.js --port 2345 --type ReactNative'
, then the command node /path/to/launchDebugger.js --port 2345 --type ReactNative /path/to/reactNative/app
will be used to start your debugger.Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.
Safari Developer Tools
You can use Safari to debug the iOS version of your app without having to enable 'Debug JS Remotely'.
- Enable Develop menu in Safari:
Preferences → Advanced → Select 'Show Develop menu in menu bar'
- Select your app's JSContext:
Develop → Simulator → JSContext
- Safari's Web Inspector should open which has a Console and a Debugger
While sourcemaps may not be enabled by default, you can follow this guide or video to enable them and set break points at the right places in the source code.
However, every time the app is reloaded (using live reload, or by manually reloading), a new JSContext is created. Choosing 'Automatically Show Web Inspectors for JSContexts' saves you from having to select the latest JSContext manually.
React Developer Tools
You can use the standalone version of React Developer Tools to debug the React component hierarchy. To use it, install the
react-devtools
package globally:Note: Version 4 of
react-devtools
requires react-native
version 0.62 or higher to work properly.Now run
react-devtools
from the terminal to launch the standalone DevTools app:It should connect to your simulator within a few seconds.
Note: if you prefer to avoid global installations, you can add
react-devtools
as a project dependency. Add the react-devtools
package to your project using npm install --save-dev react-devtools
, then add 'react-devtools': 'react-devtools'
to the scripts
section in your package.json
, and then run npm run react-devtools
from your project folder to open the DevTools.Integration with React Native Inspector
Open the in-app developer menu and choose 'Toggle Inspector'. It will bring up an overlay that lets you tap on any UI element and see information about it:
However, when
react-devtools
is running, Inspector will enter a collapsed mode, and instead use the DevTools as primary UI. In this mode, clicking on something in the simulator will bring up the relevant components in the DevTools:You can choose 'Toggle Inspector' in the same menu to exit this mode.
Inspecting Component Instances
When debugging JavaScript in Chrome, you can inspect the props and state of the React components in the browser console.
First, follow the instructions for debugging in Chrome to open the Chrome console.
Make sure that the dropdown in the top left corner of the Chrome console says
debuggerWorker.js
. This step is essential.Then select a React component in React DevTools. There is a search box at the top that helps you find one by name. As soon as you select it, it will be available as
$r
in the Chrome console, letting you inspect its props, state, and instance properties.Performance Monitor
You can enable a performance overlay to help you debug performance problems by selecting 'Perf Monitor' in the Developer Menu.
Debugging Application State
Reactotron is an open-source desktop app that allows you to inspect Redux or MobX-State-Tree application state as well as view custom logs, run custom commands such as resetting state, store and restore state snapshots, and other helpful debugging features for React Native apps.
You can view installation instructions in the README. If you're using Expo, here is an article detailing how to install on Expo.
Projects with Native Code Only
React Debugger Chrome
The following section only applies to projects with native code exposed. If you are using the managed
expo-cli
workflow, see the guide on ejecting to use this API. Accessing console logs
You can display the console logs for an iOS or Android app by using the following commands in a terminal while the app is running:
You may also access these through
Debug → Open System Log...
in the iOS Simulator or by running adb logcat *:S ReactNative:V ReactNativeJS:V
in a terminal while an Android app is running on a device or emulator.If you're using Create React Native App or Expo CLI, console logs already appear in the same terminal output as the bundler.
Debugging on a device with Chrome Developer Tools
If you're using Create React Native App or Expo CLI, this is configured for you already.
On iOS devices, open the file
RCTWebSocketExecutor.m
and change 'localhost' to the IP address of your computer, then select 'Debug JS Remotely' from the Developer Menu.On Android 5.0+ devices connected via USB, you can use the
adb
command line tool to setup port forwarding from the device to your computer:adb reverse tcp:8081 tcp:8081
Alternatively, select 'Dev Settings' from the Developer Menu, then update the 'Debug server host for device' setting to match the IP address of your computer.
If you run into any issues, it may be possible that one of your Chrome extensions is interacting in unexpected ways with the debugger. Try disabling all of your extensions and re-enabling them one-by-one until you find the problematic extension.
Debugging native code
When working with native code, such as when writing native modules, you can launch the app from Android Studio or Xcode and take advantage of the native debugging features (setting up breakpoints, etc.) as you would in case of building a standard native app.
Contents
- Android Studio
- Create & Check react-native Project
Outline
let’s see how to install and configure react-native development environment on Windows. If you want to know how to install react-native on Mac, see the blog post below.
you can use
Expo CLI
and React Native CLI
to develop react-native app on Windows.Expo CLI is the package includes many native features(geolocation, camera, etc) when you develop the app with react-native. At the first time, when you develop the react native with Expo CLI, you can feel easy and comfortable. However, this pacakge includes many native features those you don’t use, and that makes the app build size bigger. Also, if you want to integrate the native feature which Expo CLI doesn’t include, it’s hard to make it. Therefore, this blog post doesn’t recommend to use Expo CLI.
React Native Debugger Expo
This blog post is about how to install and configure React Native CLI environment. Also, we’ll create react-native project by React Native CLI and check it works well.
We need to install Nodejs, Watchman, Xcode, etc to develop the app by react-native. let’s see how to install them one by one.
Chocolatey
Chocolatey is a package manager on Windows to install and manage packages. We can install packages simply on Windows via Chocolatey.
- Chocolatey: https://chocolatey.org/
For installing Chocolatey, open Command Prompt(cmd) as Administrator, and execute the command below.
React Native Debugger Open
After installing, reopen Command Prompt(cmd), and execute the command below to check Chocolatey is installed well.
If Chocolatey is installed well, you can see Chocolatey version on the screen.
Nodejs
react-native is Javascript, so we need to install Nodejs that is Javascript runtime.
- Nodejs: https://nodejs.org/
Open Command Prompt(cmd) as Administrator, and execute Chocolatey command below to install Nodejs.
After installing, reopen Command Prompt(cmd), and execute the command below to check Nodejs is installed well.
If Nodejs is installed well, you can see Nodejs version like below.
When Nodejs is installed, basically, npm (Node Package Manager) is also installed. Execute the command below to check npm is installed well.
If npm is installed well, you can see npm version like below.
Python
React Native build system uses Python. Python is basically installed on Mac, so this procedure is not required, but on Windows, this is required.
![Native Native](https://miro.medium.com/max/5536/1*G12G8Z14IC9lirglYOR5og.png)
Open Command Prompt(cmd) as Administrator, and execute Chocolatey command below to install Python
After installing, we need to reboot the computer to use Python. After rebooting, open Command Prompt(cmd), and execute the command below to check Python is installed well.
If Python is installed well, you can see Python version like below.
React Native CLI
Let’s install React Native CLI to develop the app by react-native. Execute npm command below to install React Native CLI globally.
After installing, execute the command below to check React Native CLI is installed well.
If React Native CLI is installed well, you can see React Native CLI version like below.
JDK
We need to install JDK(Java Development Kit) to develop Android app with react-native. open Command Prompt(cmd) as Administrator, and Execute Chocolatey command below to install JDK.
After installing, reopen Command Prompt(cmd), and execute the command below to check Java is installed well.
If Java is installed well via installing JDK, you can see Java version like below.
When JDK is installed, Java compiler is alo installed. Execute the command below to check Java compiler is also installed well.
If Java compiler is installed well via installing JDK, Java compiler version is shown up like below.
Android Studio
We need to install Android Studio to develop Android app with react-native. Click the link below to go to Android Studio site and download the installation file.
- Android Studio: https://developer.android.com/studio
After downloading, execute the installation file to install Android Studio.
Android Studio Configuration
you can see the screen like below after executing Android Studio installation file.
Click Next button to go to next screen. When you go to next screen, you can see Choose Components screen like below. Select Android Virtual Device and click Next button to go to next screen.
When you go to next screen, you can see Android Studio Install Path screen like below. set Install Path or keep default, click Next button to go to next screen.
When you go to next screen, you can see Start Menu setting screen like below. Just click Install button to install.
After installing, you can see the screen like below. Click Next button to complete Android Studio installation.
When you click Next button to complete the installation, you can see the screen like below. Check Start Android Studio and click Finish button to finish Android Studio installation.
When you click Finish button, you can see Android Studio is executed like below. Select Do not import settings, and click OK button to execute Android Studio.
When you click OK button to execute Android Studio, you can see Android Studio Setup Wizard like below. Click Next button to go to next screen.
When you go to next screen, you can see Install Type screen like below. Select Custom and click Next button to go to next screen.
When you go to next screen, you can see Select UI Theme screen like below. Select the theme which you like, and click Next button to go to the next screen.
When you go to the next screen, you can see SDK Components Setup screen like below. Select
Performance (Intel ® HAXM)
option and Android Virtual Device
option, and clic Next button.React Native Debugger
on the next screen, you can see Emulator Settings screen like below. Click Next button without any changing especially.
the next process is just normal program installation, so I don’t explain the detail. Just click Finish button to continue Android studio installation to complete it.
After Android studio installation, you can see Android studio is executed like below.
Android Studio SDK Configuration
Click
Configure > SDK Manger
menu on the right botton to go to Android SDK configuration.When the screen is shown up like below, select
Show Pacakge Details
option on the right bottom. find and select the options below on the list.- Android SDK Platform 28
- Intel x86 Atom System Image
- Google APIs Intel x86 Atom System Image
- Google APIs Intel x86 Atom_64 System Image
If you select all options above, click OK button on the right bottom to install them.
Configure Android Studio Environment Variable
Android studio installation and configuration are done. Now, we need to set the environment variables. Right-click This PC and click Properties menu like below.
When you click Properties menu, you can see System and Security screen. Click Advanced System settings on the left menu list.
When you click Advanced System settings menu, you can see System properties screen like below. Click Advanced tab, and select Environment Varialbes button on the bottom of Advaced tab.
When you click Environment Variables button, you can see the dialog like below. Click New button on User variables for your name section.
When you see the dialog like above, insert
ANDROID_HOME
to Variable name, and your Android Studio SDK path to Variable value. If you don’t know your Android Studio SDK path, execute ANdroid Studio SDK confiruation screen like below. you can see Android Studio SDK location on the top of the Android Studio SDK configuration screen.When you’ve added ANDROID_HOME environment variable, you need to set Android Studio platform-tools path. Click
Path
variable on User variables for your name list to go to the edit dialog.When you can see the screen like above, insert platform-tools folder paht in Android SDK path like
C:Users[user name]AppDataLocalAndroidSdkplatform-tools
to the bottom of the list and click OK button.After that, open Command Prompt(cmd) and execute the command below.
If the environment variables are configured well, you can see the result like below.
React Native Debugger Download
Create & Check react-native Project
React Native Debugger Mac Download Version
Sometimes, the react-native app is not working or can’t be built after updating the version. Therefore, it’s recommended to execute the npm command below to lock the version when you develop the app with react-native.
execute React Native CLI command below to create react-native project.
Check on Android
In Android, execute the command below after connecting the device that the developer mode is activated via USB or executing Android studio emulator.
If you don’t have any problen, you can see the screen like below.
Completed
We’ve seen how to install and configure react-native to develop the app on Windows. Also, We’ve created the app by React Native CLI and executed it to check the environment is configured well.
Now, we are ready to develop the app with react-native. Let’s dive to the react-native development world!
Github Sponsor