diff --git a/src/components/ListBox.tsx b/src/components/ListBox.tsx index f69b320f..9f0bf77e 100644 --- a/src/components/ListBox.tsx +++ b/src/components/ListBox.tsx @@ -89,11 +89,12 @@ const ScrollContainer = styled.div( }) ) -function propsToTextValue({ - textValue, - children, - label, -}: Record) { +function propsToTextValue(props: Record | null | undefined) { + if (!props) { + return '' + } + const { textValue, children, label } = props + return typeof textValue === 'string' && textValue ? textValue : typeof label === 'string' && label @@ -126,20 +127,22 @@ function useItemWrappedChildren( ) } Children.forEach(children, (child) => { - const { textValue: _, ...childProps } = child.props - - if (child) { - const item = ( - - {cloneElement(child, childProps)} - - ) - - wrapped.push(item) + if (!child) { + return } + + const { textValue: _, ...passThruProps } = child.props || {} + + const item = ( + + {cloneElement(child, passThruProps)} + + ) + + wrapped.push(item) }) if (footer) {