- React Design Patterns and Best Practices(Second Edition)
- Carlos Santana Roldán
- 148字
- 2021-06-24 15:43:37
DOM elements and React components
With JSX, we can create both HTML elements and React components; the only difference is whether or not they start with a capital letter.
For example, to render an HTML button, we use <button />, while to render the Button component we use <Button />.
The first button is transpiled into the following:
React.createElement('button');
The second one is transpiled into the following:
React.createElement(Button);
The difference here is that in the first call we are passing the type of the DOM element as a string, while in the second call we are passing the component itself, which means that it should exist in the scope to work.
As you may have noticed, JSX supports self-closing tags, which are pretty good for keeping the code terse and do not require us to repeat unnecessary tags.
推薦閱讀
- Mastering Node.js(Second Edition)
- EJB 3.1從入門到精通
- 數據通信網絡實踐:基礎知識與交換機技術
- 物聯網安全(原書第2版)
- TCP/IP入門經典(第5版)
- SD-WAN架構與技術(第2版)
- 面向云平臺的物聯網多源異構信息融合方法
- Socket.IO Real-time Web Application Development
- 4G小基站系統原理、組網及應用
- TD-LTE無線網絡規劃與設計
- Android UI Design
- Getting Started with Memcached
- Hands-On Microservices with Node.js
- 云計算技術與標準化
- SEO攻略:搜索引擎優化策略與實戰案例詳解