Type alias ParamsType<Component>

ParamsType<Component>: {
    getChildren?: ((element) => ReactElement[]);
    match?: ((element, query) => boolean);
}

Additional parameters for searching inside exotic elements

Type Parameters

  • Component extends keyof JSX.IntrinsicElements | ComponentType<any>

Type declaration

  • Optional getChildren?: ((element) => ReactElement[])
      • (element): ReactElement[]
      • Get children from the element of the exotic component, e.g. other prop for rendering children or render props

        search(
        <ExoticComponent>
        {() => (
        <button>
        Test
        </button>
        )}
        </ExoticComponent>,
        {
        component: 'button',
        },
        {
        getChildren: (
        element,
        ) => {
        if (element.type === ExoticComponent) {
        return [element.props.children()];
        }

        return defaultGetChildren(element);
        },
        },
        )

        Parameters

        • element: ReactElement

          Target react element

        Returns ReactElement[]

        List of child nodes

  • Optional match?: ((element, query) => boolean)
      • (element, query): boolean
      • Check if the target element is matching for search, e.g.

        search(
        <ComponentWithCustomClassNameProp
        customClassName="foo bar baz"
        />,
        {
        className: 'bar',
        },
        {
        match: (
        element,
        query,
        ) => {
        if (element.type === ComponentWithCustomClassNameProp) {
        return element.props.customClassName.split(' ').includes(query.className);
        }

        return defaultMatch(element, query);
        },
        },
        )

        Parameters

        • element: ReactElement

          Target react element

        • query: QueryType<Component>

          Current query

        Returns boolean

        Is element matching for current query

Generated using TypeDoc