react / react/react-native

Key error shows internal code frames

Open
#41,945 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

DX Impact: Regression LogBox Needs: Attention Never gets stale Tech: Bundler 📦
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Description

In LogBox, when there's a key error from React, the code frame should point to the application code causing the issue, but in 0.73 (and maybe other versions) it points to the react-jsx-runtime:

Screenshot 2023-12-14 at 1 05 06 PM

The fix is to add '/node_modules/react/cjs/react-jsx-runtime.+\\.js', to the config here:

https://github.com/facebook/react-native/blob/main/packages/metro-config/index.js#L15

Really we should probably have all of '/node_modules/react/.+\\.js$', there.

Steps to reproduce
  1. trigger key error
  2. open logbox warning
  3. see wrong code frame
React Native Version

0.73.0

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info
No
Stacktrace or Logs
No
Reproducer

No

Screenshots and Videos

Above

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/metro-config/index.js around line 15, where the code-frame configuration is defined. Reproduce the key error in LogBox and inspect which React runtime file is selected instead of the application source. Done means the warning points to the application code rather than an internal react-jsx-runtime file.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, react-native
Domain
mobile, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.