feathericons / react-feather

React component for Feather icons
https://npm.im/react-feather
MIT License
1.93k stars 126 forks source link

Ref is working with icons, but is not present on Icon type #78

Open filingroove opened 3 years ago

filingroove commented 3 years ago

I'm moving a project to TypeScript and I can't use ref :)

The code:

<Info size={ 14 } color="#BDC1C7" ref={ infoIcon } />

The compiler error:

Type error: Type '{ size: number; color: string; ref: MutableRefObject<SVGElement>; }' is not assignable to type 'IntrinsicAttributes & Props & { children?: ReactNode; }'.
  Property 'ref' does not exist on type 'IntrinsicAttributes & Props & { children?: ReactNode; }'. Did you mean 'href'?

Not sure what type to use for forwardRef function component, but seems like FC doesn't include any ref property 🤔

filingroove commented 3 years ago

Got it working by adding ref?: RefObject<SVGElement>

rformato commented 1 year ago

Having the same issue

tounsoo commented 6 months ago

Same here