JSX được Babel (hoặc các compiler khác như SWC) transpile thành các lời gọi hàm tạo element của React.
Trước React 17, nó được compile thành React.createElement(type, props, ...children).
Ví dụ:
<h1 className="title">Hello</h1>Sẽ trở thành:
React.createElement("h1", { className: "title" }, "Hello")Kể từ React 17 (với JSX Transform mới), có thể sử dụng JSX mà không cần import React vì nó sử dụng các hàm đặc biệt (như _jsx từ react/jsx-runtime).
JSX is transpiled by Babel (or other compilers like SWC) into React element creation function calls.
Before React 17, it compiled to React.createElement(type, props, ...children).
Example:
<h1 className="title">Hello</h1>Becomes:
React.createElement("h1", { className: "title" }, "Hello")Since React 17 (with the new JSX Transform), you can use JSX without import React because it uses special functions (like _jsx from react/jsx-runtime).