Skip to content

Instantly share code, notes, and snippets.

@jhonsore
Last active March 17, 2021 19:23
Show Gist options
  • Save jhonsore/ac988c8fa026425e133c6e12111b443d to your computer and use it in GitHub Desktop.
Save jhonsore/ac988c8fa026425e133c6e12111b443d to your computer and use it in GitHub Desktop.
Typescript tips
import React from 'react';
interface Props extends React.ButtonHTMLAttributes<HTMLButtonElement>{
text: string;
}
const Input: React.FC<Props> = props => {
return <button { ...props }>{props.text}</button>
}
export default Input;
import React, { InputHTMLAttributes } from 'react';
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
name: string;
}
const Input: React.FC<InputProps> = props => {
return <input { ...props } />
}
export default Input;
/**
This code creates a simple react input component with Typescript
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment