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

@@ -0,0 +1,13 @@
import { Children, type ReactNode } from "react"
export function checkForEmptyChildren(children: ReactNode) {
return Children.toArray(children).filter((child) => {
if (child === "") {
return false
} else if (child == null) {
return false
} else {
return true
}
}).length
}