- ReactJS by Example:Building Modern Web Applications with React
- Vipul A M Prathamesh Sonpatki
- 126字
- 2021-07-09 19:36:59
HTML tags vs React components
"Mike, I am intrigued by one more thing. In JSX, we are mixing the React components as if they are simple HTML tags. We did this in our first component."
ReactDOM.render(<App headings = {['When', 'Who', 'Description']} data = {data} />, document.getElementById('container'));
"The App
tag is not a valid HTML tag here. But this still works."
"Yes. That's because we can specify both HTML tags and React components in JSX. There is a subtle difference though. HTML tags start with a lowercase letter and React components start with an uppercase letter." Mike explained.
// Specifying HTML tags render: function(){ return(<table className = 'table'> ..... </table>); } // Specifying React components var App = React.createClass({..}); ReactDOM.render(<App headings = {['When', 'Who', 'Description']} data = {data} />, document.getElementById('container'));
"That's the primary difference. JSX uses this convention to differentiate between the local component classes and HTML tags."
推薦閱讀
- Oracle WebLogic Server 12c:First Look
- Mastering ServiceStack
- JavaScript 網頁編程從入門到精通 (清華社"視頻大講堂"大系·網絡開發視頻大講堂)
- Learning Data Mining with Python
- Magento 2 Development Cookbook
- EPLAN實戰設計
- JavaScript入門經典
- Visual C#.NET程序設計
- Kotlin編程實戰:創建優雅、富于表現力和高性能的JVM與Android應用程序
- Kotlin開發教程(全2冊)
- Getting Started with Python and Raspberry Pi
- TypeScript 2.x By Example
- Python程序設計教程
- 深度學習入門:基于Python的理論與實現
- Java高手是怎樣煉成的:原理、方法與實踐