Skip to content
Prev Previous commit
Next Next commit
Use ReactNodeArray instead of duplicating it
  • Loading branch information
sarayourfriend committed May 21, 2021
commit 00d4bfaaf591973d40b5cc756a2a432a3054ac73
6 changes: 2 additions & 4 deletions packages/components/src/ui/utils/get-valid-children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type { ReactNode, ReactElement } from 'react';
import type { ReactNode, ReactNodeArray } from 'react';

/**
* WordPress dependencies
Expand All @@ -16,9 +16,7 @@ import { Children, isValidElement } from '@wordpress/element';
*
* @return An array of available children.
*/
export function getValidChildren(
children: ReactNode
): ( ReactElement | ReactNode )[] {
export function getValidChildren( children: ReactNode ): ReactNodeArray {
if ( typeof children === 'string' ) return [ children ];

return Children.toArray( children ).filter( ( child ) =>
Expand Down