And if you forgot to pass userId in App.tsx then the compiler would let you know that you made a mistake. If someone later refactors LoginButton to add another mandatory property, then the compiler will let you know that you forgot to circle back to App.tsx.
Yup, TSX is super helpful.
Let's say you have loginComponent.tsx that defines the following component:
You can then have a main component (typically called App.tsx) like this:
And if you forgot to pass
userId
in App.tsx then the compiler would let you know that you made a mistake. If someone later refactorsLoginButton
to add another mandatory property, then the compiler will let you know that you forgot to circle back to App.tsx.Nice. Better to use the language than the react specifc prop checks IMHO