- Hands-On Design Patterns with React Native
- Mateusz Grzesiukiewicz
- 199字
- 2021-08-13 15:12:58
Introduction to JSX
We have been using JSX so far, but what does it mean? JSX stands for JavaScript extension. How can it be an extension?
As you probably know, ECMAScript is also an extension to JavaScript (kind of). ECMAScript transpiles to JavaScript. What does this mean? It means that it just transforms ECMAScript code into valid JavaScript code. JavaScript misses out on many features that we like from ECMAScript, such as arrow functions, classes, and destructuring operators.
JSX works the same way. JSX is being transpiled to JavaScript, and its main feature is creating React elements based on the markup you write.
Could we use only JavaScript? Yes. Is it worth it? Most likely not.
Let's check this out in action. This is JSX and ECMAScript:
export default () => <Text style={{marginTop: 30}}>Example Text!</Text>
Now, compare this to pure JavaScript:
export default function() {
return React.createElement(
Text,
{style: {marginTop: 30}},
'Example Text!'
);
}
There's no doubt that the first code snippet is easier to read and understand.
- SOA實踐
- Docker進階與實戰
- Arduino by Example
- Python for Secret Agents:Volume II
- Mastering Python Scripting for System Administrators
- 區塊鏈:以太坊DApp開發實戰
- Oracle Database 12c Security Cookbook
- 微信小程序入門指南
- 移動界面(Web/App)Photoshop UI設計十全大補
- 網絡數據采集技術:Java網絡爬蟲實戰
- C#程序設計基礎入門教程
- Kotlin進階實戰
- Java程序設計
- Bitcoin Essentials
- Python Django Web從入門到項目實戰(視頻版)