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

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

主站蜘蛛池模板: 台南县| 谷城县| 江孜县| 双城市| 庆阳市| 福安市| 莆田市| 云霄县| 北宁市| 福泉市| 墨玉县| 黑水县| 区。| 五指山市| 崇明县| 绥滨县| 资源县| 娄烦县| 南投县| 诸暨市| 公安县| 微山县| 崇仁县| 屏南县| 旌德县| 阳高县| 揭阳市| 黔西县| 咸阳市| 凤城市| 六安市| 巴东县| 台江县| 南通市| 达孜县| 禄丰县| 乌什县| 禄丰县| 昌邑市| 东海县| 扶绥县|