...

/

JSX in TypeScript and React Components

JSX in TypeScript and React Components

Learn how to use JSX syntax in TypeScript and embed HTML directly into our React components.

We'll cover the following...

JSX

As mentioned earlier, React uses a specific syntax for embedding what looks like HTML directly into our JavaScript code. This syntax is known as JavaScript XML or simply JSX. TypeScript has supported the JSX syntax from very early releases, with one main caveat. If we need to use JSX syntax, then our TypeScript file should be named .tsx instead of the normal .ts. With this in mind, let’s modify the generated src/App.tsx file and replace the contents with the following:

Access this course and 1400+ top-rated courses and projects.