* Walks up the fiber tree to find the nearest component with _debugSource * * @param fiber - Starting fiber node * @param maxDepth - Maximum tree depth to traverse (default: 50) * @returns Object with source info and component name, or null
( fiber: ReactFiber, maxDepth = 50 )
| 282 | * @returns Object with source info and component name, or null |
| 283 | */ |
| 284 | function findDebugSource( |
| 285 | fiber: ReactFiber, |
| 286 | maxDepth = 50 |
| 287 | ): { source: ReactFiber["_debugSource"]; componentName: string | null } | null { |
| 288 | let current: ReactFiber | null | undefined = fiber; |
| 289 | let depth = 0; |
| 290 | |
| 291 | while (current && depth < maxDepth) { |
| 292 | // Check current fiber for debug source |
| 293 | if (current._debugSource) { |
| 294 | return { |
| 295 | source: current._debugSource, |
| 296 | componentName: getComponentName(current), |
| 297 | }; |
| 298 | } |
| 299 | |
| 300 | // Check debug owner (for components that wrap the element) |
| 301 | if (current._debugOwner?._debugSource) { |
| 302 | return { |
| 303 | source: current._debugOwner._debugSource, |
| 304 | componentName: getComponentName(current._debugOwner), |
| 305 | }; |
| 306 | } |
| 307 | |
| 308 | // Move up the tree |
| 309 | current = current.return; |
| 310 | depth++; |
| 311 | } |
| 312 | |
| 313 | return null; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * Attempts to find source location using React 19's potentially different structure |
no test coverage detected
searching dependent graphs…