Templarian / MaterialDesign-React

Dist for Material Design Icons React Component for JS/TypeScript
https://materialdesignicons.com
MIT License
139 stars 20 forks source link

Can't use 'onClick' on Icon in Typescript #80

Closed yh54321 closed 1 year ago

yh54321 commented 1 year ago

The onClick attribute can be used without issue on <Icon /> components in JavaScript as follows: <Icon className="helpButton" path={mdiHelpBox} onClick={() => showHelp(helpModalData)} />

However in Typescript, I get the following error: Property 'onClick' does not exist on type 'IntrinsicAttributes & IconProps'.ts(2322)

It would appear that the intended way of resolving this is to wrap the <Icon /> in an additional element and give the outer element the onClick attribute.

It would be nice if onClick attributes could be given directly to Icon components, especially considering that there is no issue with doing so at runtime.

yh54321 commented 1 year ago

I see this was addressed #36