icons-pack / react-simple-icons

📦 This package provides the Simple Icons packaged as a set of React components.
MIT License
287 stars 18 forks source link

onPointerEnterCapture Errors #215

Closed jd-carroll closed 4 months ago

jd-carroll commented 5 months ago

I am getting errors from the IconType stating onPointerEnterCapture and onPointerLeaveCapture are missing. But when I try to add an empty handler I receive DOM errors:

app-index.js:33 Warning: Unknown event handler property `onPointerEnterCapture`. It will be ignored.
    at svg
    at SiX2 (webpack-internal:///(app-pages-browser)/../../node_modules/@icons-pack/react-simple-icons/icons/SiX.mjs:12:11)
    at button
    at eval (webpack-internal:///(app-pages-browser)/../../node_modules/@radix-ui/themes/dist/cjs/components/base-button.js:32:19)
    at eval (webpack-internal:///(app-pages-browser)/../../node_modules/@radix-ui/themes/dist/cjs/components/icon-button.js:32:22)

My default is to always assume I am doing something wrong... ?

But this is really weird, anyone seen this before?

jd-carroll commented 5 months ago

Just did some additional investigating and I do not see either of those attributes defined in @types/react https://github.com/DefinitelyTyped/DefinitelyTyped/blob/2f4238e22773624585ec81994bf54ef9873f5e2c/types/react/ts5.0/index.d.ts#L2487-L2488

(which is why those types come up as untyped required attributes)

But how has no one else run into this issue?

jd-carroll commented 5 months ago

Last thing, wouldn't it be better to structure IconType as:

type IconType = React.ForwardRefExoticComponent<
  Omit<React.SVGProps<SVGSVGElement>, 'title' | 'color' | 'size'> & {
    title?: string;
    color?: string;
    size?: string | number;
  } & React.RefAttributes<SVGSVGElement>
>;
sfyr111 commented 5 months ago

Hello everyone,

I've submitted a PR #216 that aims to resolve the type error issue highlighted in issue #215 by removing the onPointerEnterCapture and onPointerLeaveCapture from the type declarations, syncing with the recent updates to React's type definitions. I would greatly appreciate any feedback or suggestions on this solution.

Thank you for your time and looking forward to any further discussion!

cschroeter commented 5 months ago

This is only an issue for "@types/react": "18.2.67"

For a workaround you can downgrade to 18.2.62 - if only React would have been written in TypeScript...

wootsbot commented 4 months ago

solved #216