Skip to content

Commit 9ebab38

Browse files
committed
fix: explicitly throw error when RestrictedContent child is a fragment
1 parent f6974e2 commit 9ebab38

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/RestrictedContent/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ const RestrictedContent = forwardRef<
3838
percent,
3939
}));
4040

41-
return cloneElement(Children.only(children), {
41+
const child = Children.only(children);
42+
43+
if (child?.type === Symbol.for('react.fragment')) {
44+
throw new Error('RestrictedContent cannot accept a Fragment as a child.');
45+
}
46+
47+
return cloneElement(child, {
4248
ref: contentRef,
4349
});
4450
});

0 commit comments

Comments
 (0)