426 | {/* asChild must be true */}
427 |
431 |
432 | )
433 | }
434 | ```
435 |
436 | ## Types or Interfaces?
437 |
438 | `interface`s are different from `type`s in TypeScript, but they can be used for very similar things as far as common React uses cases are concerned. Here's a helpful rule of thumb:
439 |
440 | - Always use `interface` for public API's definition when authoring a library or 3rd party ambient type definitions.
441 |
442 | - Consider using `type` for your React Component Props and State, because it is more constrained.
443 |
444 | Types are useful for union types (e.g. `type MyType = TypeA | TypeB`) whereas Interfaces are better for declaring dictionary shapes and then `implementing` or `extending` them.
445 |
446 | ## Resources
447 |
448 | - [React Total Typescript](https://www.totaltypescript.com/tutorials/react-with-typescript)
449 | - [Discriminated Unions are a Frontend Dev's Best Friend](https://www.totaltypescript.com/discriminated-unions-are-a-devs-best-friend)
450 | - [Other React TypeScript Cheatsheets
451 | ](https://react-typescript-cheatsheet.netlify.app/)
452 |
--------------------------------------------------------------------------------
/event-handler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ibnumusyaffa/simple-react-typescript-cheatsheet/816d4f8eef95be74989f1c241dbb4719d65d0f6c/event-handler.png
--------------------------------------------------------------------------------