-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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: Display root type for root updates in "what caused this update?" #22599
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import * as React from 'react'; | |
import {useContext} from 'react'; | ||
import {ProfilerContext} from './ProfilerContext'; | ||
import styles from './Updaters.css'; | ||
import {ElementTypeRoot} from '../../../types'; | ||
|
||
export type Props = {| | ||
commitTree: CommitTree, | ||
|
@@ -26,8 +27,9 @@ export default function Updaters({commitTree, updaters}: Props) { | |
const children = | ||
updaters.length > 0 ? ( | ||
updaters.map<React$Node>((serializedElement: SerializedElement) => { | ||
const {displayName, id, key} = serializedElement; | ||
const isVisibleInTree = commitTree.nodes.has(id); | ||
const {displayName, id, key, type} = serializedElement; | ||
const isVisibleInTree = | ||
commitTree.nodes.has(id) && type !== ElementTypeRoot; | ||
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems a bit sketchy. Ideally we had some unified notion of what's visible in the tree instead of each component checking that logic. But maybe this is fine for now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably okay for now. |
||
if (isVisibleInTree) { | ||
return ( | ||
<button | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a bit misleading for the new roots since it's not actaully the
createRoot()
call butcreateRoot().render()
.Could also do
return `render(${getDisplayNameForRoot(fiber)})`;
but that's misleading for legacyReactDOM.hydrate()
.Open to suggestions here. Mainly opening this to draw attention to the fact that updates to roots are displayed as "anonymous"