@@ -352,34 +352,7 @@ The tool console in this sandbox stands in for Chrome DevTools MCP so you can tr
352352
353353Components are identified by short, stable uids like ` "r5" ` . A uid stays the same across every tool and across re-renders, but not across page reloads.
354354
355- Every tool returns a plain, serializable value. If a tool fails, it returns a ` ToolError ` instead. The return types below use these shared types:
356-
357- ``` ts
358- type ToolError = {
359- error: string ;
360- };
361-
362- type NodeType =
363- | ' root' | ' function' | ' class' | ' host' | ' text' | ' forwardRef' | ' memo'
364- | ' context' | ' fragment' | ' mode' | ' portal' | ' profiler' | ' suspense'
365- | ' suspenseList' | ' lazy' | ' activity' | ' viewTransition' | ' offscreen'
366- | ' cache' | ' scope' | ' throw' | ' dehydrated' | ' unknown' ;
367-
368- type TreeNode = {
369- uid: string ;
370- type: NodeType ;
371- name: string ;
372- key: string | null ;
373- firstChild: string | null ; // uid of the first child, if any
374- nextSibling: string | null ; // uid of the next sibling, if any
375- };
376-
377- type ComponentBranchEntry = {
378- uid: string ;
379- name: string ;
380- type: NodeType ;
381- };
382- ```
355+ Every tool returns a plain, serializable object. If a tool fails, it returns an object with an ` error ` message instead.
383356
384357#### ` react_get_component_tree ` {/* react_get_component_tree* /}
385358
@@ -392,13 +365,15 @@ Returns a snapshot of the component tree of every mounted root.
392365
393366##### Returns {/* react_get_component_tree-returns* /}
394367
395- ``` ts
396- type Result = {
397- nodes: Array <TreeNode >;
398- } | ToolError ;
399- ```
368+ ` react_get_component_tree ` returns an object with one property:
400369
401- ` nodes ` is a flat list. Use ` firstChild ` and ` nextSibling ` to rebuild the tree.
370+ * ` nodes ` : A flat array of the components in the tree. Each node has these properties:
371+ * ` uid ` : The component's uid.
372+ * ` type ` : The kind of node, like ` "function" ` , ` "class" ` , ` "host" ` , ` "memo" ` , ` "forwardRef" ` , ` "context" ` , ` "suspense" ` , or ` "root" ` .
373+ * ` name ` : The component's name, or the tag name for host components.
374+ * ` key ` : The component's [ ` key ` ] ( /learn/rendering-lists#keeping-list-items-in-order-with-key ) , or ` null ` .
375+ * ` firstChild ` : The uid of the first child, or ` null ` .
376+ * ` nextSibling ` : The uid of the next sibling, or ` null ` .
402377
403378#### ` react_find_components ` {/* react_find_components* /}
404379
@@ -413,15 +388,13 @@ Finds components whose name contains a substring, ignoring case.
413388
414389##### Returns {/* react_find_components-returns* /}
415390
416- ``` ts
417- type Result = {
418- page: number ;
419- pageSize: number ;
420- totalCount: number ;
421- totalPages: number ;
422- results: Array <TreeNode >;
423- } | ToolError ;
424- ```
391+ ` react_find_components ` returns an object with these properties:
392+
393+ * ` results ` : The matching components on this page, as nodes in the same shape as [ ` react_get_component_tree ` ] ( #react_get_component_tree ) returns.
394+ * ` page ` : The current page.
395+ * ` pageSize ` : The number of results per page.
396+ * ` totalCount ` : The total number of matching components.
397+ * ` totalPages ` : The total number of pages.
425398
426399#### ` react_get_component_by_uid ` {/* react_get_component_by_uid* /}
427400
@@ -434,23 +407,16 @@ Returns the props and, optionally, the Hooks of one component.
434407
435408##### Returns {/* react_get_component_by_uid-returns* /}
436409
437- ``` ts
438- type Result = {
439- uid: string ;
440- type: NodeType ;
441- name: string ;
442- key? : string ;
443- props? : { [name : string ]: unknown }; // without `children`
444- hooks? : Array <HookNode >; // only when `includeHooks` is true
445- } | ToolError ;
446-
447- type HookNode = {
448- id: number | null ; // null for custom Hooks
449- name: string ; // for example, "State" or "Effect"
450- value: unknown ;
451- subHooks: Array <HookNode >; // Hooks called by a custom Hook
452- };
453- ```
410+ ` react_get_component_by_uid ` returns an object with these properties:
411+
412+ * ` uid ` , ` type ` , ` name ` : The same as in [ ` react_get_component_tree ` ] ( #react_get_component_tree ) .
413+ * ` key ` : The component's ` key ` , if it has one.
414+ * ` props ` : The component's props, without ` children ` .
415+ * ` hooks ` : Only when ` includeHooks ` is ` true ` . An array of the component's Hooks. Each Hook has these properties:
416+ * ` id ` : The Hook's index, or ` null ` for custom Hooks.
417+ * ` name ` : The Hook's name, like ` "State" ` or ` "Effect" ` .
418+ * ` value ` : The Hook's current value.
419+ * ` subHooks ` : For a custom Hook, the Hooks it calls.
454420
455421##### Caveats {/* react_get_component_by_uid-caveats* /}
456422
@@ -468,15 +434,7 @@ Returns the React host component for a DOM element, for example the `<button>` t
468434
469435##### Returns {/* react_get_component_by_dom_element-returns* /}
470436
471- ``` ts
472- type Result = {
473- uid: string ;
474- type: ' host' ;
475- name: string ; // the tag name, for example "button"
476- key? : string ;
477- props? : { [name : string ]: unknown };
478- } | ToolError ;
479- ```
437+ ` react_get_component_by_dom_element ` returns an object with the same properties as [ ` react_get_component_by_uid ` ] ( #react_get_component_by_uid ) , without ` hooks ` . Its ` type ` is always ` "host" ` .
480438
481439#### ` react_get_parent_stack ` {/* react_get_parent_stack* /}
482440
@@ -488,11 +446,7 @@ Returns where a component is mounted in the rendered tree, from its immediate pa
488446
489447##### Returns {/* react_get_parent_stack-returns* /}
490448
491- ``` ts
492- type Result = Array <ComponentBranchEntry > | ToolError ;
493- ```
494-
495- The array is empty for a root.
449+ ` react_get_parent_stack ` returns an array of the component's parents, from its immediate parent up to the root. Each parent has a ` uid ` , a ` name ` , and a ` type ` , the same as in [ ` react_get_component_tree ` ] ( #react_get_component_tree ) . The array is empty for a root.
496450
497451#### ` react_get_owner_stack ` {/* react_get_owner_stack* /}
498452
@@ -510,11 +464,7 @@ The **parent** of a component is where it's mounted in the tree. The **owner** i
510464
511465##### Returns {/* react_get_owner_stack-returns* /}
512466
513- ``` ts
514- type Result = Array <ComponentBranchEntry > | ToolError ;
515- ```
516-
517- The array is empty for a root component and in production builds.
467+ ` react_get_owner_stack ` returns an array of the component's owners, from its immediate owner up to the root owner. Each owner has a ` uid ` , a ` name ` , and a ` type ` , the same as in [ ` react_get_component_tree ` ] ( #react_get_component_tree ) . The array is empty for a root component and in production builds.
518468
519469#### ` react_get_owner_stack_trace ` {/* react_get_owner_stack_trace* /}
520470
@@ -526,13 +476,9 @@ Returns the raw [owner stack](/reference/react/captureOwnerStack) of a component
526476
527477##### Returns {/* react_get_owner_stack_trace-returns* /}
528478
529- ``` ts
530- type Result = {
531- stack: string ; // same format as Error.prototype.stack
532- } | ToolError ;
533- ```
479+ ` react_get_owner_stack_trace ` returns an object with one property:
534480
535- ` stack ` is empty in production builds.
481+ * ` stack ` : A string in the same format as an [ ` Error ` stack ] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack ) . It's empty in production builds.
536482
537483#### ` react_get_component_source ` {/* react_get_component_source* /}
538484
@@ -544,18 +490,9 @@ Returns where a component is defined.
544490
545491##### Returns {/* react_get_component_source-returns* /}
546492
547- ``` ts
548- type Result = {
549- source: {
550- name: string ;
551- fileName: string ;
552- line: number ;
553- column: number ;
554- } | null ;
555- } | ToolError ;
556- ```
493+ ` react_get_component_source ` returns an object with one property:
557494
558- ` source ` is ` null ` for host components and in production builds. The location points at the code the browser loaded, so it may need source maps to map back to your files.
495+ * ` source ` : An object with the component's ` name ` , ` fileName ` , ` line ` , and ` column ` . It's ` null ` for host components and in production builds. The location points at the code the browser loaded, so it may need source maps to map back to your files.
559496
560497#### ` react_start_profiling ` {/* react_start_profiling* /}
561498
@@ -567,14 +504,12 @@ Starts recording render timing for every commit, like the Profiler tab in React
567504
568505##### Returns {/* react_start_profiling-returns* /}
569506
570- ``` ts
571- type Result = {
572- status: ' started' ;
573- traceName: string ;
574- } | ToolError ;
575- ```
507+ ` react_start_profiling ` returns an object with these properties:
576508
577- Returns a ` ToolError ` if a profiling session is already running.
509+ * ` status ` : Always ` "started" ` .
510+ * ` traceName ` : The name of the trace.
511+
512+ It returns an error if a profiling session is already running.
578513
579514#### ` react_stop_profiling ` {/* react_stop_profiling* /}
580515
@@ -586,15 +521,13 @@ Stops the running profiling session.
586521
587522##### Returns {/* react_stop_profiling-returns* /}
588523
589- ``` ts
590- type Result = {
591- status: ' stopped' ;
592- traceName: string ;
593- commits: number ; // number of commits recorded
594- } | ToolError ;
595- ```
524+ ` react_stop_profiling ` returns an object with these properties:
596525
597- Returns a ` ToolError ` if no profiling session is running.
526+ * ` status ` : Always ` "stopped" ` .
527+ * ` traceName ` : The name of the trace.
528+ * ` commits ` : The number of commits recorded.
529+
530+ It returns an error if no profiling session is running.
598531
599532#### ` react_get_trace_overview ` {/* react_get_trace_overview* /}
600533
@@ -606,16 +539,14 @@ Returns one row per commit in a recorded trace.
606539
607540##### Returns {/* react_get_trace_overview-returns* /}
608541
609- ``` ts
610- type Result = Array <{
611- commit: number ; // commit index, starting from 0
612- committedAt: number ; // ms since profiling started
613- renderDuration: number | null ; // ms spent rendering
614- layoutDuration: number | null ; // ms spent in layout effects
615- passiveDuration: number | null ; // ms spent in passive effects
616- componentsChanged: number ;
617- }> | ToolError ;
618- ```
542+ ` react_get_trace_overview ` returns an array with one entry per commit. Each entry has these properties:
543+
544+ * ` commit ` : The commit's index, starting from ` 0 ` .
545+ * ` committedAt ` : When the commit happened, in milliseconds since profiling started.
546+ * ` renderDuration ` : Milliseconds spent rendering components.
547+ * ` layoutDuration ` : Milliseconds spent in layout effects, like [ ` useLayoutEffect ` ] ( /reference/react/useLayoutEffect ) .
548+ * ` passiveDuration ` : Milliseconds spent in passive effects, like [ ` useEffect ` ] ( /reference/react/useEffect ) .
549+ * ` componentsChanged ` : The number of components that rendered.
619550
620551Durations are ` null ` when the React build doesn't collect profiling timing.
621552
@@ -630,22 +561,14 @@ Returns which components rendered in one commit of a recorded trace, and how lon
630561
631562##### Returns {/* react_get_commit_report-returns* /}
632563
633- ``` ts
634- type Result = {
635- committedAt: number ;
636- priority: ' Sync' | ' UserBlocking' | ' Normal' | ' Idle' ;
637- renderDuration: number | null ;
638- layoutDuration: number | null ;
639- passiveDuration: number | null ;
640- components: Array <{
641- uid: string ;
642- name: string ;
643- type: NodeType ;
644- actualDuration: number | null ; // ms rendering the component and its children
645- selfDuration: number | null ; // ms rendering only the component itself
646- }>; // sorted by actualDuration, slowest first
647- } | ToolError ;
648- ```
564+ ` react_get_commit_report ` returns an object with these properties:
565+
566+ * ` committedAt ` , ` renderDuration ` , ` layoutDuration ` , ` passiveDuration ` : The same as in [ ` react_get_trace_overview ` ] ( #react_get_trace_overview ) .
567+ * ` priority ` : The priority of the update, one of ` "Sync" ` , ` "UserBlocking" ` , ` "Normal" ` , or ` "Idle" ` .
568+ * ` components ` : The components that rendered, slowest first. Each component has these properties:
569+ * ` uid ` , ` name ` , ` type ` : The same as in [ ` react_get_component_tree ` ] ( #react_get_component_tree ) .
570+ * ` actualDuration ` : Milliseconds spent rendering the component and its children.
571+ * ` selfDuration ` : Milliseconds spent rendering only the component itself.
649572
650573---
651574
0 commit comments