在使用Typescript和React时,我们需要在tsconfig.json
文件的compilerOptions
中指定jsx
。
可以使用preserve
、react
、react-native
、react-jsx
等值。
{
"compilerOptions": {
"jsx": "react-jsx" | "react" | "react-native" | "preserve"
}
}
react
和react-jsx
主要用于Web开发。
我想了解这两个选项之间的区别,以及在何时选择哪一个。
react
将jsx转换为React.createElement()
react-jsx
将jsx转换为_jsx()
和_jsxs()
此外,_jsx()
和_jsxs()
之间有什么区别?