Skip to content

Instantly share code, notes, and snippets.

@italosantana
Created May 18, 2022 13:33
Show Gist options
  • Save italosantana/784bf5291f2541f3fd32e3518e049fd3 to your computer and use it in GitHub Desktop.
Save italosantana/784bf5291f2541f3fd32e3518e049fd3 to your computer and use it in GitHub Desktop.
Jsx property
jsx property allows us to use .tsx files in the project
So following are two steps of using React with Typescript
1.Name your files with a .tsx extension
2.Enable the jsx option
TypeScript ships with three JSX modes: preserve, react, and react-native.
These modes only affect the emit stage - type checking is unaffected.
The preserve mode will keep the JSX as part of the output to be further consumed by another transform step (e.g. Babel). Additionally, the output will have a .jsx file extension.
The react mode will emit React.createElement, does not need to go through a JSX transformation before use, and the output will have a .js file extension.
The react-native mode is the equivalent of preserve in that it keeps all JSX, but the output will instead have a .js file extension.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment