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

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

主站蜘蛛池模板: 碌曲县| 观塘区| 安乡县| 苍溪县| 噶尔县| 息烽县| 上栗县| 黔南| 江北区| 辉南县| 南部县| 七台河市| 新郑市| 丘北县| 翼城县| 南靖县| 同德县| 同江市| 慈利县| 乐至县| 安平县| 汶上县| 邛崃市| 岳普湖县| 钟山县| 娱乐| 天长市| 察隅县| 修文县| 平利县| 永清县| 顺义区| 临猗县| 盐山县| 连山| 贵阳市| 那坡县| 周宁县| 平和县| 富平县| 重庆市|