It also would be better to use Extract on the shared button props to extract only InputHTMLAttributes<HTMLInputElement> props for <button {...extractedProps}>. In case if you decided to use some custom props for example loading: boolean it will also be sent to <button/> and cause warnings that your loading prop is not in default button props.
I'm a little confused. You keep saying this provides "strict" typing, which I assume you mean strong typing. Since typescript happens before runtime and converts the code to javascript which will be executed in a javascript runtime, which is weakly typed your code will also be weakly typed. Typescript won't magically make the javascript runtime strongly typed. Are you meaning to say it provides static typing? Sorry, this very much is a semantic issue I'm trying to clarify.
You can also use
React.FCinstead ofReact.FunctionComponent😃Thx) Awesome!
Nice article! you've made a small typo
should be Component or .FC
React.FCandReact.FunctionComponentis the sameYeah I know but look closely.
thepracticaldev.s3.amazonaws.com/i...
Oh, sorry! Thanks)
Instead of
defaultProps, I use:It also would be better to use Extract on the shared button props to extract only
InputHTMLAttributes<HTMLInputElement>props for<button {...extractedProps}>. In case if you decided to use some custom props for exampleloading: booleanit will also be sent to<button/>and cause warnings that yourloadingprop is not in default button props.I'm a little confused. You keep saying this provides "strict" typing, which I assume you mean strong typing. Since typescript happens before runtime and converts the code to javascript which will be executed in a javascript runtime, which is weakly typed your code will also be weakly typed. Typescript won't magically make the javascript runtime strongly typed. Are you meaning to say it provides static typing? Sorry, this very much is a semantic issue I'm trying to clarify.
I mean, that you have typings better than
anyand unnecessary to declare each native html property.Although, there are differences between interface extends and &