fix: filter out empty children

This commit is contained in:
Christel Westerberg
2024-06-18 15:15:15 +02:00
parent ceee9fd154
commit 928b2af698
3 changed files with 17 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
import { Slot } from "@radix-ui/react-slot"
import { Children } from "react"
import { checkForEmptyChildren } from "../../utils/checkForEmptyChildren"
import { subtitleVariants } from "./variants"
import type { SubtitleProps } from "./subtitle"
@@ -13,7 +13,7 @@ export default function Subtitle({
textTransform,
...props
}: SubtitleProps) {
if (Children.toArray(props.children).length === 0) {
if (checkForEmptyChildren(props.children) === 0) {
return null
}
const Comp = asChild ? Slot : "p"