Replies: 1 comment 2 replies
-
you need to mix type, like this: import { JSX } from 'preact'
type ComponentProps = { /* your custom prop */ } & JSX.HTMLAttributes<HTMLButtonElement>
const MyComponent = (props: ComponentProps) => {
return <button {...props}>Hello World</button>
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm struggling to properly type a component in Preact. I want to pass the HTML tag the component should be rendered with as a string.
Here's some code to explain myself (and here's a playground on Stackblitz: https://stackblitz.com/edit/preact-tsx-starter-hbjjaq?file=App.tsx):
Beta Was this translation helpful? Give feedback.
All reactions