getComponentData function extracts the underlying component data from a child builder function by inspecting its AST structure. It unwraps modifiers to find the core component and returns its name and props.
Parameters
child- A function that returns a component
Returns
Returns aComponentData object containing:
Usage
Extract component information
Inspect modified components
The function unwraps modifiers likeModifiedComponent or DOMIdentifiable to find the core component:
Conditional rendering based on component type
Validating child component types
Creating wrapper components with introspection
Extracting props for debugging
Notes
- The function inspects the component’s AST structure to retrieve information
- Modifiers are automatically unwrapped to find the core component
- If the component cannot be identified,
namewill benull - The returned props are the direct props passed to the component, not computed values
- This is useful for creating wrapper components that need to inspect their children
- The function does not execute the component, it only analyzes its structure
- Custom components defined with
defineComponentwill return their registered name - Built-in components return their standard names (e.g., “Text”, “Image”, “VStack”)
