React Inspection
Register React Native JavaScript inspection tools for React component trees, shadow trees, search, navigation state, and optional component actions.
React Inspection tools are JavaScript-backed. They inspect React Fiber and React Native host-tree data rather than the platform-native view hierarchy.
Register the Suite
const reactTools = Ansight.installReactTools({
includeBounds: true,
includeProps: false,
includeState: false,
maxDepth: 30,
maxNodes: 1500,
navigationRef,
});
await reactTools.ready;
Use Ansight.uninstallReactTools() or reactTools.unregister() to remove the registrations.
Registration API
installReactTools(options): registers React inspection tools.uninstallReactTools(): unregisters React inspection tools.includeBounds: includes bounds when available.includeProps: includes sanitized props when requested.includeState: includes sanitized state when requested.maxDepth/maxNodes: cap traversal.navigationRef: enablesreact.get_navigation_state.enableActions: enablesreact.invoke_component_action.allowedActionProps: restricts invokable prop names.
Specific Concerns
- Props and state can expose app/user data. Keep them off unless needed.
- The component tree includes composite React components.
- The shadow tree is the committed React Native host tree with composites flattened out.
- React actions invoke app code and are write-scoped.
- Do not enable actions unless the app has an explicit local testing workflow for them.
Tool Matrix
| Tool id | Scope | Purpose | Security |
|---|---|---|---|
react.get_component_tree | Read | Captures the live React Fiber component tree, including composite components. | High |
react.get_shadow_tree | Read | Captures the committed React Native host tree with composites flattened out. | High |
react.find_components | Read | Searches the component tree by query, type, text, or testID. | High |
react.get_component | Read | Returns one component node by id. | High |
react.get_navigation_state | Read | Returns React Navigation state when navigationRef is supplied. | Moderate |
react.invoke_component_action | Write | Invokes an allow-listed function prop when actions are enabled. | Critical |
Component Tree
react.get_component_tree returns React Fiber component data. Use this when the workflow needs component names, parent/child structure, and optional props or state.
Shadow Tree
react.get_shadow_tree returns the committed React Native host tree. Use this when the workflow needs the rendered host layout with composite components flattened out.
Actions
Actions are opt-in:
Ansight.installReactTools({
enableActions: true,
allowedActionProps: ["onPress"],
});
Only allow the action props that are needed for the local workflow.