You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 06fd9ad
Browse filesBrowse the repository at this point in the historyBrowse files
`{nodes}`, a flat array of `{uid, type, name, key, firstChild, nextSibling}`. `firstChild` and `nextSibling` are uids of other nodes in the array, or `null`, so you can rebuild the tree from them.
400
393
@@ -410,33 +403,33 @@ Returns a snapshot of the component tree of every mounted root.
***optional**`rootUid`: Only search inside this component's subtree.
421
414
***optional**`page`: The page of results to return. Defaults to `1`.
422
415
***optional**`pageSize`: Results per page. Defaults to `10`.
423
416
424
-
**Returns**
417
+
#### Returns {/*react_find_components-returns*/}
425
418
426
419
`{page, pageSize, totalCount, totalPages, results}`, where `results` is an array of tree nodes in the same shape as [`react_get_component_tree`](#react_get_component_tree).
Returns the React host component for a DOM element, for example the `<button>` that React rendered. It returns the host node itself, not the component that rendered it. To find that component, pass the returned `uid` to [`react_get_owner_stack`](#react_get_owner_stack).
*`element`: A reference to a DOM element in the page. Chrome DevTools MCP clients pass `{uid}` using an element uid from the page snapshot (`take_snapshot`), and Chrome DevTools MCP resolves it to the real element.
React tracks two different relationships between components. The **parent** of a component is where it's mounted in the tree. The **owner** is the component that created it in its JSX. For example, in `<Card><Avatar /></Card>` written inside `Profile`, `Avatar`'s parent is `Card` but its owner is `Profile`. When an agent wants to know which code to change, owners are usually what it needs.
475
+
Returns where a component is mounted in the rendered tree.
Returns where a component is mounted in the rendered tree.
479
+
React tracks two different relationships between components. The **parent** of a component is where it's mounted in the tree. The **owner** is the component that created it in its JSX. For example, in `<Card><Avatar /></Card>` written inside `Profile`, `Avatar`'s parent is `Card` but its owner is `Profile`. When an agent wants to know which code to change, owners are usually what it needs. Use [`react_get_owner_stack`](#react_get_owner_stack) to get owners.
An array of `{uid, name, type}`, from the immediate parent up to the root. It can include host components and the root itself, and is empty for a root.
`{stack}`, a string in the same format as an `Error` stack. Pass it through source maps to get original file names and lines. It's empty in production builds.
`{source: {name, fileName, line, column}}`, or `{source: null}` when the location can't be determined, for example for host components or in production builds. `fileName`, `line`, and `column` point at the code the browser loaded, so they may need source maps to map back to your files.
537
532
538
533
---
539
534
540
-
### Profiling tools {/*profiling-tools*/}
541
-
542
-
The profiling tools record the same per-commit data as the Profiler tab in React DevTools. A typical sequence is: start profiling, perform an interaction (for example with Chrome DevTools MCP's `click`), stop profiling, then read the overview and the slowest commits.
Starts recording render timing for every commit. The profiling tools record the same per-commit data as the Profiler tab in React DevTools.
545
538
546
-
Starts recording render timing for every commit.
539
+
A typical sequence is to start profiling, perform an interaction (for example with Chrome DevTools MCP's `click`), stop profiling with [`react_stop_profiling`](#react_stop_profiling), then read [`react_get_trace_overview`](#react_get_trace_overview) and the [report](#react_get_commit_report) for the slowest commits.
`{committedAt, priority, renderDuration, layoutDuration, passiveDuration, components}`, where `components` is an array of `{uid, name, type, actualDuration, selfDuration}`, sorted from slowest to fastest `actualDuration`.
599
596
@@ -616,23 +613,40 @@ Returns details for one commit in a trace.
616
613
617
614
---
618
615
619
-
### JavaScript API {/*javascript-api*/}
620
-
621
-
The package root is side-effect free and exports lower-level functions for custom setups:
616
+
In addition to the tools, the package root is side-effect free and exports lower-level functions for custom setups:
Installs the React DevTools hook and starts answering Chrome DevTools MCP's `devtoolstooldiscovery` event. `react-devtools-cdt-mcp/register` calls it for you.
625
+
626
+
#### Parameters {/*register-parameters*/}
627
+
628
+
***optional**`target`: The global object to install the hook on and listen for discovery on. Defaults to `globalThis`.
629
+
630
+
#### Returns {/*register-returns*/}
631
+
632
+
`{facade, unregister}`. Call `unregister()` to stop answering discovery.
633
+
634
+
#### Caveats {/*register-caveats*/}
635
+
636
+
* Call `register` before React initializes, or React won't connect to the hook.
637
+
* Calling `register` again for the same `target` returns the existing registration.
638
+
639
+
### `buildToolGroup(tools)` {/*buildtoolgroup*/}
640
+
641
+
Builds the `react` tool group from a set of React DevTools tools. Use this if you want to expose the same tools through another channel.
628
642
629
-
Installs the React DevTools hook on `target` (defaults to `globalThis`) and starts answering Chrome DevTools MCP's `devtoolstooldiscovery` event. Calling it again for the same target returns the existing registration. `react-devtools-cdt-mcp/register` calls it for you.
643
+
#### Parameters {/*buildtoolgroup-parameters*/}
630
644
631
-
Returns `{facade, unregister}`. Call `unregister()` to stop answering discovery.
645
+
*`tools`: The React DevTools tools to expose.
632
646
633
-
#### `buildToolGroup(tools)` {/*buildtoolgroup*/}
647
+
#### Returns {/*buildtoolgroup-returns*/}
634
648
635
-
Builds the `react` tool group, `{name, description, tools}`, from a set of React DevTools tools. Each tool has `{name, description, inputSchema, execute}`. Use this if you want to expose the same tools through another channel.
649
+
`{name, description, tools}`, where each tool has `{name, description, inputSchema, execute}`.
0 commit comments