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

DOM elements and React components

With JSX, we can create both HTML elements and React components; the only difference is whether or not they start with a capital letter.

For example, to render an HTML button, we use <button />, while to render the Button component we use <Button />.

The first button is transpiled into the following:

  React.createElement('button');

The second one is transpiled into the following:

  React.createElement(Button);

The difference here is that in the first call we are passing the type of the DOM element as a string, while in the second call we are passing the component itself, which means that it should exist in the scope to work.

As you may have noticed, JSX supports self-closing tags, which are pretty good for keeping the code terse and do not require us to repeat unnecessary tags.

主站蜘蛛池模板: 池州市| 紫金县| 刚察县| 巨鹿县| 红河县| 萨嘎县| 皮山县| 偏关县| 修武县| 保康县| 宁阳县| 盖州市| 肇东市| 阳春市| 景谷| 合作市| 连州市| 武冈市| 仁寿县| 北碚区| 建阳市| 大埔区| 乌恰县| 肇东市| 隆安县| 和硕县| 喀喇沁旗| 绥中县| 汾西县| 九龙县| 上虞市| 云龙县| 申扎县| 岢岚县| 阿荣旗| 光山县| 会东县| 涞水县| 湟中县| 大埔区| 南宁市|