AFAIK, the iconButton should behaves as a button, so it should be able to received onClick property.
I've tried something like this:
<IconButton onClick={() => {console.log("whatever")} {...more properties} >{children}</IconButton>
But I get a typescript compilation error because onClick property is not available.
I think the problem is with the types definition https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/theme-ui__components/index.d.ts#L335 because it uses BoxProps instead of IconButtonProps. Does it make sense?
The issue title says “not compiling in JavaScript” but you mention it’s a TypeScript error. Is the onClick not working on the frontend, or is it just a TypeScript error?
Sorry, my mistake. I've just changed the title. It's in Typescript where I get the compilation error
I haven’t used Theme UI with TypeScript, but I’d expect Theme UI doesn’t do anything about onClick or other event handlers—you can pass any arbitrary props to Theme UI components, Theme UI won’t validate them in any capacity. Should the library be doing something different here?
Typescript does not allow to add onClick property to the iconButton because it's not in their available properties because according to https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/theme-ui__components/index.d.ts#L335 the iconButton has the properties of BoxProps instead of the IconButtonProps.
I've just seen that I created the bug in the wrong repository. I'm quite new in Typescript and thought that types were maintained and pushed to DeclarationTypes from here but I think that repo has its own flow. Sorry for the noise here @lachlanjc , I'll close the issue
@jjballano-qatium Did you solve this? Where did you create the issue in DefinitelyTyped? I am facing the exact same issue.
@martpie I've created a PR that will be merged soon (hopefully) https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44107