MCPcopy Create free account
hub / github.com/primer/react / getChildIcon

Function getChildIcon

packages/react/src/SegmentedControl/SegmentedControl.tsx:81–91  ·  view source on GitHub ↗
(childArg: React.ReactNode)

Source from the content-addressed store, hash-verified

79 ? React.Children.toArray(children)[selectedIndex]
80 : undefined
81 const getChildIcon = (childArg: React.ReactNode) => {
82 if (
83 React.isValidElement<SegmentedControlButtonProps>(childArg) &&
84 childArg.type === Button &&
85 childArg.props.leadingIcon
86 ) {
87 return childArg.props.leadingIcon
88 }
89
90 return React.isValidElement<SegmentedControlIconButtonProps>(childArg) ? childArg.props.icon : null
91 }
92 const getChildText = (childArg: React.ReactNode) => {
93 if (React.isValidElement<SegmentedControlButtonProps>(childArg) && childArg.type === Button) {
94 return childArg.props.children

Callers 1

RootFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected