Skip to content

TypeScript Support for PassThrough components #118

Answered by rtivital
Pernick asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, thanks for feedback!

I guess this should help with these kind of components – https://mantine.dev/core/button/#typescript

Usually it's just enough to use first generic argument to get most of the types coverage:

<Button<"a">
  component="a"
  href="https://mantine.dev"
  onClick={(event) => event.preventDefault()}
>
  Mantine
</Button>

In case you need correct types in elementRef prop – provide additional generic type (by default it will be HTMLButtonElement in this example without second type):

<Button<"a", HTMLAnchorElement>
  component="a"
  href="https://mantine.dev"
  onClick={(event) => event.preventDefault()}
  elementRef={node => console.log(node)}
>
  Mantine
</Button>

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Pernick
Comment options

@Pernick
Comment options

@rtivital
Comment options

@Pernick
Comment options

@rtivital
Comment options

Answer selected by Pernick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants