- 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.
- Drupal 8 Blueprints
- Responsive Web Design with HTML5 and CSS3
- 新編Premiere Pro CC從入門(mén)到精通
- Visual Basic程序設(shè)計(jì)習(xí)題解答與上機(jī)指導(dǎo)
- 零基礎(chǔ)入門(mén)學(xué)習(xí)Python
- Serverless架構(gòu)
- Linux:Embedded Development
- 持續(xù)輕量級(jí)Java EE開(kāi)發(fā):編寫(xiě)可測(cè)試的代碼
- 21天學(xué)通C++(第5版)
- Learning Hadoop 2
- 代替VBA!用Python輕松實(shí)現(xiàn)Excel編程
- 零基礎(chǔ)學(xué)C++(升級(jí)版)
- 從零開(kāi)始構(gòu)建深度前饋神經(jīng)網(wǎng)絡(luò):Python+TensorFlow 2.x
- Spring Boot從入門(mén)到實(shí)戰(zhàn)
- 從零開(kāi)始學(xué)算法:基于Python