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

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

主站蜘蛛池模板: 淮南市| 宁波市| 青神县| 兴安县| 德昌县| 金川县| 清水河县| 南雄市| 舟曲县| 彰化县| 滨海县| 五华县| 贺兰县| 卓资县| 延吉市| 新津县| 昌都县| 米林县| 田林县| 清河县| 岳普湖县| 镇江市| 怀柔区| 石河子市| 云南省| 图们市| 定日县| 扶沟县| 高密市| 泾源县| 石渠县| 万安县| 隆尧县| 耒阳市| 舒城县| 万荣县| 巫溪县| 梅河口市| 重庆市| 汾阳市| 南江县|