(
+ ({ elementRef, ...rest }, ref) => (
+ {
+ elementRef?.(el)
+ if (typeof ref === 'function') ref(el)
+ }}
+ {...rest}
+ >
+ {COMPONENT_TEXT}
+
+ )
+ ) as any
+ AcceptingChild.displayName = 'AcceptingChild'
+ AcceptingChild.allowedProps = ['elementRef']
+
+ const { getByText } = render(
+
+
+
+ )
+
+ // the child's own elementRef is chained, not overwritten
+ await waitFor(() => {
+ expect(childElementRef).toHaveBeenCalledWith(expect.any(Element))
+ })
+ expect(getByText(COMPONENT_TEXT)).not.toHaveAttribute('elementref')
+ })
+ })
})