- ReactJS by Example:Building Modern Web Applications with React
- Vipul A M Prathamesh Sonpatki
- 356字
- 2021-07-09 19:36:59
Transforming JSX into JavaScript
"Shawn, as I mentioned, the JSX is transformed to the native JavaScript syntax."
// Input (JSX): var app = <App name="Mike" />;
"This will eventually get transformed to"
// Output (JS): var app = React.createElement(App, {name:"Mike"});
Tip
Downloading the example code
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
- Log in or register to our website using your e-mail address and password.
- Hover the mouse pointer on the SUPPORT tab at the top.
- Click on Code Downloads & Errata.
- Enter the name of the book in the Search box.
- Select the book for which you're looking to download the code files.
- Choose from the drop-down menu where you purchased this book from.
- Click on Code Download.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR / 7-Zip for Windows
- Zipeg / iZip / UnRarX for Mac
- 7-Zip / PeaZip for Linux
"If you would like to see this live in action, try this example at https://babeljs.io/repl/. It's a live REPL that can transform a JSX code to the native JavaScript code."
"There is another editor available for converting HTML to JSX. You can check it out at http://facebook.github.io/react/html-jsx.html. This allows you to paste an arbitrary HTML code that gets converted to JSX with extraction of styles, classes, and other information and then create a component on top of it." said Mike.
"Pretty handy. However, this is just for ease of development, right? What happens when we deploy our code?" asked Shawn.
"JSX is not meant to be compiled at runtime. Though there is a JSX transformer that converts JSX to JavaScript in a browser. Using it to compile JSX at runtime in the browser would slow down our application. We will use tools such as Babel, which is a JavaScript transpiler to convert our JSX code to the native JavaScript code before deploying the application."
- Advanced Quantitative Finance with C++
- Boost.Asio C++ Network Programming(Second Edition)
- LabVIEW 2018 虛擬儀器程序設計
- Java入門經典(第6版)
- Java面向對象軟件開發
- 垃圾回收的算法與實現
- vSphere High Performance Cookbook
- 零基礎玩轉區塊鏈
- Raspberry Pi for Secret Agents(Third Edition)
- Python高級機器學習
- Learning Firefox OS Application Development
- JavaScript從入門到精通(第3版)
- Python Data Analysis(Second Edition)
- Visual Basic程序設計實驗指導(第4版)
- 計算機應用基礎實踐教程