Last active
March 22, 2020 20:18
-
-
Save francoisgeorgy/ab48fc666c85638068b9e795159e2b4f to your computer and use it in GitHub Desktop.
#react #typescript props
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface IButtonProps { | |
| text: string, | |
| type: ButtonTypes, | |
| action: () => void | |
| } | |
| const ExtendedButton : React.FC<IButtonProps> = ({text, type, action}) => { | |
| //... | |
| } | |
| // We extend the FC (Functional Component) type with our own custom interface. | |
| // Better: | |
| interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | |
| text: string, | |
| type: ButtonTypes, | |
| action: () => void | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment