Description
Description
related potentially, but not exactly - #2457
This would not be necessary if we passed rendered elements as props instead of passing components (as the linked PR above suggests)
Primer defines some props that accept function components however they don't accept things like forwardRef components, memoized components or lazy components (at least)
Where does this show up?
Places like this one -
react/src/TextInput/TextInput.tsx
Line 137 in 21fa73c
this should render anything that's component-like, and not just function components, but it only handles function components.
something like this using react-is might be what we want here, with type updates to match
import {isValidElementType} from 'react-is'
{isValidElementType(LeadingVisual) ? <LeadingVisual /> : LeadingVisual}
When using primer/octicons-react version 19+, these components break because icons are all forwardRef
components in that version
Attempting to use v19+ in github/github
also trips these failures - https://github.com/github/github/pull/276931
Steps to reproduce
Attempt to pass a memoized, lazy or ref forwarding component to a leadingVisual
Version
latest
Browser
No response