上QQ阅读APP看书,第一时间看更新
Props
JSX is very convenient when your DOM elements or React components have props. Using XML is pretty easy to set attributes on elements:
<img src="https://www.dev.education/images/logo.png" alt="DEV
Education" />
The equivalent in JavaScript would be as follows:
React.createElement("img", {
src: "https://www.dev.education/images/logo.png",
alt: "DEV Education"
});
This is far less readable, and even with only a couple of attributes it is harder to read without a bit of reasoning.