We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
React.isValidElement()
Children.only()
1 parent e968a1a commit 3d9b5e7Copy full SHA for 3d9b5e7
packages/react/src/components/factory.ts
@@ -53,13 +53,13 @@ const withAsChild = (Component: React.ElementType) => {
53
if (!asChild) {
54
return createElement(Component, { ...restProps, ref }, children)
55
}
56
-
57
- const onlyChild: React.ReactNode = Children.only(children)
58
59
- if (!isValidElement<Record<string, unknown>>(onlyChild)) {
+
+ if (!isValidElement<Record<string, unknown>>(children)) {
60
return null
61
62
+ const onlyChild: React.ReactNode = Children.only(children)
63
const childRef = getRef(onlyChild)
64
65
return cloneElement(onlyChild, {
0 commit comments