DEV Community

Discussion on: Stop using loading spinners

Collapse
 
nandotherojo profile image
Fernando Rojo

This is a fantastic question. The reason is, this way you can destructure your props in the component. Try doing it your way, and then see what happens to TypeScript in the component if you try to destructure props.artist.

By using never or undefined, we allow ourselves to at least see the destructured variables in the component.

However, you are correct. Your example is the safest. You’ll just have to make sure that you always check for props.loading before using props.artist.

Since my example fixes this at the consumption step of the component, it isn’t technically needed.

Hope that helps!