Reagieren Sie die Länge der Kinder

/**
2 * Gets only the valid children of a component,
3 * and ignores any nullish or falsy child.
4 *
5 * @param children the children
6 */
7export function getValidChildren(children: React.ReactNode) {
8  return React.Children.toArray(children).filter((child) =>
9    React.isValidElement(child),
10  ) as React.ReactElement[]
11}
Guy Cohen