Skip to content

Commit cf5e8c1

Browse files
authored
Refactor how ref is passed in cloneElement- Fix broken tests (#623)
1 parent 7dcdcec commit cf5e8c1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/core/primitives/Primitive/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ const createPrimitiveComponent = (elementType: SupportedElement) => {
1616
const { asChild = false, children, ...elementProps } = props;
1717

1818
if (asChild && React.isValidElement(children)) {
19-
return React.cloneElement(children, { ...elementProps, ref });
19+
return React.cloneElement(children, {
20+
...elementProps,
21+
ref
22+
} as React.HTMLAttributes<HTMLElement>);
2023
}
2124

2225
return React.createElement(elementType, { ...elementProps, ref }, children);

0 commit comments

Comments
 (0)