Hello there. I very like to use React and Typescript. Almost in each new project need simple components, like atoms, for example: button, input, ch...
For further actions, you may consider blocking this person and/or reporting abuse
You can also use
React.FC
instead ofReact.FunctionComponent
😃Thx) Awesome!
Nice article! you've made a small typo
should be Component or .FC
React.FC
andReact.FunctionComponent
is 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: boolean
it will also be sent to<button/>
and cause warnings that yourloading
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.
I mean, that you have typings better than
any
and unnecessary to declare each native html property.Although, there are differences between interface extends and &