MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ClearSlots

Function ClearSlots

packages/@adobe/react-spectrum/src/utils/Slots.tsx:67–80  ·  view source on GitHub ↗
(props: {children?: ReactNode})

Source from the content-addressed store, hash-verified

65}
66
67export function ClearSlots(props: {children?: ReactNode}): ReactNode {
68 let {children, ...otherProps} = props;
69
70 const emptyObj = useMemo(() => ({}), []);
71
72 let content = children;
73 if (React.Children.toArray(children).length <= 1) {
74 if (typeof children === 'function') {
75 // need to know if the node is a string or something else that react can render that doesn't get props
76 content = React.cloneElement(React.Children.only(children), otherProps);
77 }
78 }
79 return <SlotContext.Provider value={emptyObj}>{content}</SlotContext.Provider>;
80}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected