File tree Expand file tree Collapse file tree 2 files changed +10
-25
lines changed
packages/react-devtools-shared/src/devtools Expand file tree Collapse file tree 2 files changed +10
-25
lines changed Original file line number Diff line number Diff line change @@ -854,10 +854,11 @@ export default class Store extends EventEmitter<{
854854 const lineage : Array < SuspenseNode [ 'id' ] > = [ ] ;
855855 let next : null | SuspenseNode = this . getSuspenseByID ( suspenseID ) ;
856856 while ( next !== null ) {
857+ // Include Root to be able to see what suspended the Shell.
858+ lineage . unshift ( next . id ) ;
857859 if ( next . parentID === 0 ) {
858860 next = null ;
859861 } else {
860- lineage . unshift ( next . id ) ;
861862 next = this . getSuspenseByID ( next . parentID ) ;
862863 }
863864 }
@@ -1205,7 +1206,7 @@ export default class Store extends EventEmitter<{
12051206 this . _idToElement . set ( id , {
12061207 children : [ ] ,
12071208 depth : - 1 ,
1208- displayName : null ,
1209+ displayName : 'React Root' ,
12091210 hocDisplayNames : null ,
12101211 id,
12111212 isCollapsed : false , // Never collapse roots; it would hide the entire tree.
@@ -1539,7 +1540,12 @@ export default class Store extends EventEmitter<{
15391540 if ( name === null ) {
15401541 // The boundary isn't explicitly named.
15411542 // Pick a sensible default.
1542- name = this . _guessSuspenseName ( element ) ;
1543+ if ( parentID === 0 ) {
1544+ // For Roots we use their display name.
1545+ name = element . displayName ;
1546+ } else {
1547+ name = this . _guessSuspenseName ( element ) ;
1548+ }
15431549 }
15441550 }
15451551
Original file line number Diff line number Diff line change @@ -161,27 +161,6 @@ function getDocumentBoundingRect(
161161 } ;
162162}
163163
164- function SuspenseRectsShell ( {
165- rootID,
166- } : {
167- rootID : SuspenseNode [ 'id' ] ,
168- } ) : React$Node {
169- const store = useContext ( StoreContext ) ;
170- const root = store . getSuspenseByID ( rootID ) ;
171- if ( root === null ) {
172- console . warn ( `<Element> Could not find suspense node id ${ rootID } ` ) ;
173- return null ;
174- }
175-
176- return (
177- < g >
178- { root . children . map ( childID => {
179- return < SuspenseRects key = { childID } suspenseID = { childID } /> ;
180- } ) }
181- </ g >
182- ) ;
183- }
184-
185164function SuspenseRectsContainer ( ) : React$Node {
186165 const store = useContext ( StoreContext ) ;
187166 // TODO: This relies on a full re-render of all children when the Suspense tree changes.
@@ -202,7 +181,7 @@ function SuspenseRectsContainer(): React$Node {
202181 style = { { width, height} }
203182 viewBox = { `${ boundingRect . x } ${ boundingRect . y } ${ boundingRect . width } ${ boundingRect . height } ` } >
204183 { roots . map ( rootID => {
205- return < SuspenseRectsShell key = { rootID } rootID = { rootID } /> ;
184+ return < SuspenseRects key = { rootID } suspenseID = { rootID } /> ;
206185 } ) }
207186 </ svg >
208187 </ div >
You can’t perform that action at this time.
0 commit comments