-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type-hinting functional components with JSX attributes? #1
Comments
Like this maybe? import { h } from "preact";
export interface ButtonProps {
title: string;
}
export const Button = (props: JSX.HTMLAttributes) => {
const { title, ...rest } = props;
return <button {...rest}>{title}</button>;
}; |
Hmm, no, that doesn't give me access to |
Sorry it took me a little while to get around to this, but it looks like preactjs/preact#1033 may have solved the issue? It's not been released yet, but using the updated definition it appears your examples now work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this brilliant source of reference! Really cuts through the noise :-)
What's missing for me, is how to type-hint a functional component that accepts standard JSX attributes?
I tried the following:
But I get the following error:
Clearly, type-hinting as
FunctionalComponent<ButtonProps>
isn't the right way to go about this?The text was updated successfully, but these errors were encountered: