为什么我们应该在 React-Native 中使用 tsx 而不是简单的 .js?
Why we should use tsx instead of simple .js in React-Native?
我想知道人们在 react-native project
中使用 .tsx
文件格式。这 2 个文件格式 .tsx 和 .js 之间的 difference
是什么。
TSX 是将 JSX 与打字稿一起使用时应该使用的扩展。
在这里引用 TS 文档..
JSX is an embeddable XML-like syntax. It is meant to be transformed
into valid JavaScript, though the semantics of that transformation are
implementation-specific. JSX rose to popularity with the React
framework, but has since seen other implementations as well.
TypeScript supports embedding, type checking, and compiling JSX
directly to JavaScript. Basic usage
In order to use JSX you must do two things.
Name your files with a .tsx extension
Enable the jsx option
https://www.typescriptlang.org/docs/handbook/jsx.html
如果您将 JSX 与 JavaScript 一起使用,您可以使用 .JS 或 .JSX,这取决于您。
我想知道人们在 react-native project
中使用 .tsx
文件格式。这 2 个文件格式 .tsx 和 .js 之间的 difference
是什么。
TSX 是将 JSX 与打字稿一起使用时应该使用的扩展。
在这里引用 TS 文档..
JSX is an embeddable XML-like syntax. It is meant to be transformed into valid JavaScript, though the semantics of that transformation are implementation-specific. JSX rose to popularity with the React framework, but has since seen other implementations as well. TypeScript supports embedding, type checking, and compiling JSX directly to JavaScript. Basic usage
In order to use JSX you must do two things.
Name your files with a .tsx extension Enable the jsx option
https://www.typescriptlang.org/docs/handbook/jsx.html
如果您将 JSX 与 JavaScript 一起使用,您可以使用 .JS 或 .JSX,这取决于您。