官术网_书友最值得收藏!

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."

主站蜘蛛池模板: 土默特左旗| 右玉县| 修水县| 邯郸市| 香港 | 谢通门县| 甘南县| 梓潼县| 德格县| 县级市| 宜都市| 建德市| 平凉市| 宜都市| 体育| 阿瓦提县| 三都| 平和县| 临洮县| 南昌市| 南溪县| 修水县| 资阳市| 讷河市| 象州县| 阳谷县| 普兰店市| 松原市| 云浮市| 景宁| 逊克县| 平舆县| 蓝田县| 泾源县| 望都县| 获嘉县| 镇远县| 滦南县| 长子县| 临猗县| 壶关县|