What does JSX stand for?

早过忘川 提交于 2019-11-28 17:24:13

问题


What does JSX stand for?

I am referring to the JSX that is defined as a XML-like syntax extension to ECMAScript, which has become quite popular with the increasing popularity of ReactJS.


回答1:


JSX stands for JavaScript XML. With React, it's an extension for XML-like code for elements and components. Per the React docs and as you mentioned:

JSX is a XML-like syntax extension to ECMAScript without any defined semantics

From the quote above, you can see that JSX doesn't have defined semantics, it's just an extension to JavaScript that allows to write XML-like code for simplicity and elegance, and then you transpile the JSX into pure JavaScript function calls with React.createElement. Per the React tutorial:

JSX is a preprocessor step that adds XML syntax to JavaScript. You can definitely use React without JSX but JSX makes React a lot more elegant.

Just like XML, JSX tags have a tag name, attributes, and children. If an attribute value is enclosed in quotes, the value is a string. Otherwise, wrap the value in braces and the value is the enclosed JavaScript expression.

Any code in JSX is transformed into plain JavaScript/ECMAScript. Consider a component called Login. Now we render it like so with JSX:

<Login foo={...} bar={...} />

As you can see, JSX just allows you to have XML-like syntax for tags, representing components and elements in React. It's transpiled into pure JavaScript:

React.createElement(Login, { foo: ..., bar: ... });

You can read more at the docs.




回答2:


JSXJavaScript stand for syntax extension.It's similar to XML. You can use a simple JSX syntactic transform with React.




回答3:


JSX - JavaScript Syntax Extension A preprocessor step that adds XML syntax to JavaScript




回答4:


JSX stand for Javascript with XML like syntax

 eg.
<div>
</div>
or <td>
</td>

same like XML format put it in return form in class defined



来源:https://stackoverflow.com/questions/39461805/what-does-jsx-stand-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!