Command C Activates Chrome Dev

We've created a set of resources to help you ensure your site remains available and accessible to all during the COVID-19 situation.

Jan 14, 2019 Command click to add multiple cursors in the Sources Panel. Chrome Dev Summit 2014: Let's build some apps with Polymer! See the Google Developers Site. Opening Devtools To access the DevTools, on any web page or app in Google Chrome you can use one of these options: Open the Chrome menu at the top-right of your browser window, then select Tools Developer Tools. Right-click on any page element and select Inspect Element. Enable Chrome debug logging to a file by passing -enable-logging -v=1 command-line flags at startup. Debug builds place the chromedebug.log file in the outDebug directory. Release builds place the file in the top level of the user data Chromium app directory, which is OS-version-dependent. By default, Commands are scoped to the Chrome browser, which means that while the browser does not have focus, the shortcut will be inactive. On desktop Chrome, Commands can instead have global scope, as of version 35, and will then also work while Chrome does.not. have focus. Jul 03, 2019  NB: The Browser Console command line (to execute JavaScript expressions) is disabled by default. To enable it set the devtools.chrome.enabled preference to true in about:config, or set the 'Enable browser chrome and add-on debugging toolboxes' (Firefox.

There are many ways to open Chrome DevTools, because different users want fast access to differentparts of the DevTools UI.

Open the Elements panel to inspect the DOM or CSS

When you want to inspect a DOM node's styles or attributes, right-click the elementand select Inspect.

Or press Command+Option+C (Mac) orControl+Shift+C (Windows, Linux, Chrome OS).

See Get Started With Viewing And Changing CSS.

Open the Console panel to view logged messages or run JavaScript

Press Command+Option+J(Mac) or Control+Shift+J (Windows, Linux, Chrome OS) tojump straight into the Console panel.

See Get Started With The Console.

Open the last panel you had open

Press Command+Option+I (Mac) orControl+Shift+I.

Open DevTools from Chrome's main menu

Click Customize and control Google Chrome and then select More Tools > Developer Tools.

Auto-open DevTools on every new tab

Open Chrome from the command line and pass the --auto-open-devtools-for-tabs flag.

Mac:

Feedback

Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.

Command C Activates Chrome Dev Update

Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.
Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.
Dev
Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.
Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.
Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.
Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.
Command C Activates Chrome Dev
Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.
Dev
Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.
Thank you for the feedback. If you have specific ideas on how to improve this page, please create an issue.

Accessing the In-App Developer Menu

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.

In-app Errors and Warnings

Errors and warnings are displayed inside your app in development builds.

Errors

In-app errors are displayed in a full screen alert with a red background inside your app. This screen is known as a RedBox. You can use console.error() to manually trigger one.

Warnings

Warnings will be displayed on screen with a yellow background. These alerts are known as YellowBoxes. Click on the alerts to show more information or to dismiss them.

As with a RedBox, you can use console.warn() to trigger a YellowBox.

YellowBoxes can be disabled during development by using console.disableYellowBox = true;. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored:

In CI/Xcode, YellowBoxes can also be disabled by setting the IS_TESTING environment variable.

RedBoxes and YellowBoxes are automatically disabled in release (production) builds.

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, CtrlShiftI 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.

Command C Activates Chrome Dev Download

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

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 packager.

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

Command C Activates Chrome Dev Key

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.