为什么 Atom 不接受 JSX 文件的语法?

Why Atom does not accept the syntax of JSX file?

我这里有这个表达式:

<QRCode
  value={`${formattedBchAddress}`}
  style={{ alignSelf: "center" }}
/>

Atom 不接受它,尽管从语法上看它是正确的。

我的回答是假设您没有安装提供 JSX 高亮显示的包,而是使用内置的 language-javascript。由于 JSX 不是 ECMAScript 标准的一部分,我认为你不应该期望 JavaScript 语言语法支持它。

幸运的是,有流行的 language-babel which includes JSX support among other things. While this is the package with the most downloads and ratings, let me also point out that there are alternatives 可供选择。