Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevTools Bug]: React 17 error while trying to inspect hooks "Context reads do not line up with context dependencies." #28960

Closed
gdeedlerthryv opened this issue Apr 30, 2024 · 7 comments · Fixed by #28974
Assignees
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@gdeedlerthryv
Copy link

Website or app

https://github.com/gdeedlerthryv/react-dev-tools-test/

Repro steps

  1. Inspect TestApp component
  2. Get error
backendManager.js:117 React DevTools encountered an error while trying to inspect hooks. This is most likely caused by an error in current inspected component: "TestApp".
The error thrown in the component is: 

 Error: Context reads do not line up with context dependencies. This is a bug in React Debug Tools.
    at H (react-debug-tools.production.min.js:14:310)
    at Proxy.useContext (react-debug-tools.production.min.js:18:40)
    at Object.useContext (chunk-GGTEBMAR.js?v=b51a6ac3:1125:29)
    at useLocation (chunk-PFB6EJD6.js?v=b51a6ac3:3382:16)
    at TestApp (main.jsx:13:20)
    at R (react-debug-tools.production.min.js:32:287)
    at exports.inspectHooksOfFiber (react-debug-tools.production.min.js:35:150)
    at inspectElementRaw (renderer.js:3379:36)
    at Object.inspectElement (renderer.js:3716:38)
    at agent.js:420:18

Screenshot 2024-04-30 at 3 58 07 PM

Issue was introduced by DevTools 5.1.0 release, I think this PR is the culprit. I built the 5.0.2 extension and the error did not occur:
Screenshot 2024-04-30 at 3 57 37 PM

I wasn't able to repro the issue without external libraries, but someone who knows better probably could.

How often does this bug happen?

Every time

DevTools package (automated)

No response

DevTools version (automated)

No response

Error message (automated)

No response

Error call stack (automated)

No response

Error component stack (automated)

No response

GitHub query string (automated)

No response

@gdeedlerthryv gdeedlerthryv added Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels Apr 30, 2024
@eps1lon eps1lon self-assigned this May 1, 2024
@Dokki
Copy link

Dokki commented May 2, 2024

Same...
image

@eps1lon
Copy link
Collaborator

eps1lon commented May 2, 2024

Thank you for the report! The underlying cause is calling useContext multiple times in the same component with the same context.

This is only a bug with React DevTools using React 17 and below. React 18 and above work fine. Should be fixed once #28974 is released.

In the meantime, you can install the unpacked extension from the branch when working with React 17 and below. Download https://output.circle-artifacts.com/output/job/03edee00-b0d2-48a2-b4b9-7e190c1ac521/artifacts/0/build/devtools/chrome-extension.zip, unpack it, go to chrome://extensions/, enable developer mode, click on "load unpacked extension" and select the unpacked chrome-extension (and make sure to disable any previously installed React Developer Tools extension).

@gdeedlerthryv
Copy link
Author

Thank you!

@sandasan
Copy link

sandasan commented May 3, 2024

Thank you so much!

@zjtt
Copy link

zjtt commented May 14, 2024

感谢

@AllenAttuned
Copy link

Thanks for sharing the details on the issue @eps1lon. I'm looking forward to the update. Do you have a bundle for a Firefox version of the extension?

@zjtt
Copy link

zjtt commented May 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
6 participants