Typescript best practices for client-side apps written in React

1. Avoid using React.PropTypes to define component’s props if you don’t have a specific use-case Fully leveraging TypeScript’s capabilities to make your code cleaner and simplistic is the first rule when using it in combination with React. Components' accepted props should be defined either via interfaces or type aliases. If your next question is “Which one should be used when?”, the answer is that they can be used interchangeably, as they are very similar, but there should exist consistency across your codebase....

May 4, 2023 · 8 min · Lucian Costin (Lukas) Ailenei