-
Notifications
You must be signed in to change notification settings - Fork 47k
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] Improve Fast Refresh support for named hook detection #21796
Comments
To repro this case...
import React, { useState } from 'react'
export default function Example() {
const [count, setCount] = useState(0);
return count;
}
import React, { useState } from 'react'
export default function Example() {
const [bool, setBool] = useState(true);
const [count, setCount] = useState(0);
return bool + count;
}
Reloading the page will not fix this issue. Fixing this issue requires closing and re-opening DevTools. |
Fast Refresh Runtime calls |
That's an interesting idea! Let me look into that. 😄 |
"hocs" are kind of unfortunate as the concept is already confusing enough, and here we have an abbreviation. Unlike |
This was my reservation too, although I also really disliked seeing a HOC strip and a "ref" strip as separate panels. This mock/POC was trying to combine them a little. I think the concern about showing "hocs" like as a props-like-named-key is good though :( Hmmm. |
Also LOL I just realized that I left my previous comment on the wrong issue. I am so bad at context switching. |
HOCs are kind of fading away though? I don't know if they're even that common in practice in modern codebases. |
Let's move this chat to the right thread 😅 #21879 |
#21641 added support to DevTools for showing hook names for the inspected component. For performance reasons, this feature caches source maps and ASTs by file name to avoid re-parsing any time a new component is inspected.
As #21790 (comment) mentions:
So our cache may be incorrect in the case of Fast Refresh (or other hot-reloading system).
The comment goes on to say:
The trouble with this idea is that DevTools is not explicitly notified when Fast Refresh reloads a component.
The React core team has talked about the idea of adding a new, DEV-only
Remount
bit/flag to Fibers to notify DevTools of this case. That would be a helpful signal here too that any cached source/AST should be cleared when hooks are next inspected. (The flag would need to be passed from backend to frontend as part of the "inspected element" payload.)The text was updated successfully, but these errors were encountered: