- ReactJS by Example:Building Modern Web Applications with React
- Vipul A M Prathamesh Sonpatki
- 237字
- 2021-07-09 19:36:58
Why JSX?
Shawn had a great first day and he was just getting started with the next one at Adequate Consulting. With a mug of coffee, he startled Mike.
"Hey Mike, I saw that we used JSX for building our first component. Why should we use JSX when React has React.createElement
?"
"You can use React without using JSX. But JSX makes it easy to build React components. It reduces the amount of code required to write. It looks like HTML markup. Its syntax is simple and concise and it's very easy to visualize the components that are getting built."
"Take an example of the render function of a component without using JSX."
// render without JSX render: function(){ return(React.createElement("p", null, "Hello React World!")); }
"With JSX, it looks much better."
// render with JSX render: function(){ return <p> Hello React World </p>; }
"Compared to the previous non-JSX example, the JSX code is much more readable, easy to understand, and close to the actual HTML markup."
"The similarity between JSX and HTML markup means that non-developers such as UI and UX designers in the team can contribute to a project using JSX. Having XML-like tag syntax also makes reading large component trees easier compared to the function calls or object literals in JavaScript." explained Mike.
"Yeah. The syntax does look familiar. We will be using JSX all the way in our projects right?"
"Yes, we will", remarked Mike.
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- 樂學Web編程:網站制作不神秘
- C語言程序設計
- Getting Started with SQL Server 2012 Cube Development
- Python機器學習編程與實戰
- Hands-On Swift 5 Microservices Development
- Symfony2 Essentials
- UML 基礎與 Rose 建模案例(第3版)
- 軟件品質之完美管理:實戰經典
- MySQL從入門到精通(軟件開發視頻大講堂)
- Programming with CodeIgniterMVC
- Python趣味編程與精彩實例
- HTML+CSS+JavaScript網頁制作:從入門到精通(第4版)
- 零基礎學C語言(第4版)
- 物聯網系統架構設計與邊緣計算(原書第2版)