Skip to content

Instantly share code, notes, and snippets.

@amitavroy
Last active May 10, 2022 04:14
Show Gist options
  • Save amitavroy/82641de9b4d6a8ea69eaff11c8260494 to your computer and use it in GitHub Desktop.
Save amitavroy/82641de9b4d6a8ea69eaff11c8260494 to your computer and use it in GitHub Desktop.
Some useful React codes
// A sample button component with proper Typescript definitions
// and it also spreads all props coming from the parent component
import { HTMLAttributes, ReactNode } from "react";
interface Props extends HTMLAttributes<HTMLButtonElement> {
children: ReactNode;
variant: "primary" | "secondary";
}
const Button = ({ children, ...props }: Props) => {
return <button {...props}>{children}</button>;
};
export default Button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment