- 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."
推薦閱讀
- Clojure Programming Cookbook
- OpenDaylight Cookbook
- Linux C/C++服務器開發實踐
- Java從入門到精通(第4版)
- Android Application Development Cookbook(Second Edition)
- Java游戲服務器架構實戰
- 零基礎學MQL:基于EA的自動化交易編程
- BIM概論及Revit精講
- Visual Basic程序設計上機實驗教程
- 區塊鏈技術進階與實戰(第2版)
- Python爬蟲、數據分析與可視化:工具詳解與案例實戰
- Python Programming for Arduino
- 算法精解:C語言描述
- 菜鳥成長之路
- Unity虛擬現實開發圣典