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]: useEffect hook incorrectly labelled as reason for component rendering #24182

Closed
steinybot opened this issue Mar 27, 2022 · 2 comments
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@steinybot
Copy link

Website or app

https://codesandbox.io/s/react-devtools-useeffect-incorrect-render-reason-x3inwg

Repro steps

  1. Start profiling
  2. Click the button
  3. Stop profiling
  4. Check the reasons for rendering

Screen Shot 2022-03-28 at 10 48 57 AM

Screen Shot 2022-03-28 at 10 54 17 AM

It is incorrect to say that hook 2 is why this rendered. Hook 1 is why it rendered. Hook 2 was rescheduled during that render. These really need to be separated as they are completely different things. In a component with a lot of effects it can be tedious to find which hook was the one that caused it to render (especially with transpilling, minifying etc where hooks are not always shown nicely).

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

@steinybot steinybot added Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels Mar 27, 2022
@lunaruan
Copy link
Contributor

Hey! Thanks for reporting this issue and sorry for the inconvenience. We used to be able to detect the difference between a state update and an effect, but due to React reconciler changes, this seems to have broken. We're working a way to better insulate React DevTools from reconciler, and this is definitely a good candidate to add to this effort. Thanks!

@lunaruan
Copy link
Contributor

Hey! Looking at this more, isEffect is actually working. We updated this to only report stateful hooks that changed between renders. Thanks for reporting, and closing this issue!

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
Development

No branches or pull requests

2 participants