Skip to content

[docs] Overhaul "Debugging Basics" guide#3898

Merged
huntie merged 1 commit into
react:mainfrom
huntie:new-debugging-docs
Oct 24, 2023
Merged

[docs] Overhaul "Debugging Basics" guide#3898
huntie merged 1 commit into
react:mainfrom
huntie:new-debugging-docs

Conversation

@huntie

@huntie huntie commented Oct 24, 2023

Copy link
Copy Markdown
Member

This is an opinionated refresh of the "Debugging Basics" guide.

Note

Please use the hosted preview site to browse (/docs/next/debugging).

Key changes

  • Add instructions about launching the JS debugger (existing and new methods — detailed below).
  • Add "React DevTools" intro.
  • Refreshes and adds new images, tighten existing wording.
  • Remove "Safari Developer Tools" instructions (this is being imminently relocated under an "Other Debugging Methods" page).

"Opening the Debugger"

This contains three tabs of instructions which will represent available debugging options in 0.73:

  • Hermes Debugger / Expo
  • Flipper
  • New Debugger (Experimental)

Default — "Flipper" tab

  • Why this is the default selection:
    • While Flipper is going away, potentially in the next React Native release, it remains the default action for "Open Debugger" in 0.73.
    • The "In Expo projects"... notice above this should short-circuit the instructions for Expo users.
  • Ordering: The "Flipper" tab is ordered after "Hermes Debugger / Expo", since this is 1/ the Expo default today, 2/ more likely to stick around after we've removed the "Flipper" tab.
  • Sidenote: This is the first reference to Flipper in our docs(!) — but again represents the current state of the system.
image

@netlify

netlify Bot commented Oct 24, 2023

Copy link
Copy Markdown

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit 722a320
🔍 Latest deploy log https://app.netlify.com/sites/react-native/deploys/6537cf53a27c140008941478
😎 Deploy Preview https://deploy-preview-3898--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@huntie
huntie force-pushed the new-debugging-docs branch from 5c3f329 to 722a320 Compare October 24, 2023 14:06
Comment thread docs/debugging.md

Alternatively for Android devices and emulators, you can run `adb shell input keyevent 82` in your terminal.

![](/docs/assets/DevMenu.png)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: Previous asset remains referenced in the 0.72-versioned docs.

@blakef blakef left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread docs/debugging.md
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 paginate 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.
The debugger allows you to understand and debug how your JavaScript code is running, similar to a web browser.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Subjective]: The debugger allows you to understand and debug how your JavaScript application code is running. The experience is very similar to a popular web browser's debugging experience.

Comment thread docs/debugging.md

:::info
Ignore logs as a last resort and create a task to fix any logs that are ignored.
**In Expo projects**, press <kbd>j</kbd> in the CLI to directly open the Hermes Debugger.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CleanShot 2023-10-24 at 15 31 28@2x

Maybe with something similar for the new debugger?

Comment thread docs/debugging.md
// Ignore all log notifications:
LogBox.ignoreAllLogs();
```
Hermes supports the Chrome debugger by implementing the Chrome DevTools Protocol. This means Chrome's tools can be used to directly debug JavaScript running on Hermes, on an emulator or on a physical device.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a chance to link to our new generated docs?

Hermes supports the Chrome debugger by implementing the Chrome DevTools Protocol.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Opinion] I'm not sure if it's too verbose, but emphasising the application code seems important. Totally subjective perspective here.

This means Chrome's tools can be used to debug the React Native JavaScript application code running on a Hermes VM. Applications can be debugged on both emulators or physical devices.

Comment thread docs/debugging.md

### Unhandled Errors
1. In a Chrome browser window, navigate to `chrome://inspect`.
2. Use the "Configure..." button to add the dev server address (typically `localhost:8081`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typically -> by default?

Comment thread docs/debugging.md
:::

## Chrome Developer Tools
The React Native team is working on a new JavaScript debugger experience, intended to replace Flipper, with a preview available as of React Native 0.73.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Opinion]

The React Native team is working to replace Flipper witha new JavaScript debugger experience. A preview is available as of React Native 0.73.

Comment thread docs/debugging.md

:::info
**Starting from version 0.73, Remote Debugging is deprecated.** These Chrome DevTools steps use the _Remote Debugging_ workflow, where JS code is executed in Chrome's V8 engine on the dev machine during debugging, instead of on-device. This method is incompatible with some New Architecture features such as JSI.
The new debugger can be enabled via React Native CLI. This will also enable <kbd>j</kbd> to debug.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Opinion]
To use the new debugger, start your React Native application with this experimental flag:

npx react-native start --experimental-debugger

You can then launch the debugger by pressing j. A video might also be useful?

CleanShot.2023-10-24.at.16.02.08.mp4

@huntie
huntie merged commit f6360b2 into react:main Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants