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

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.

主站蜘蛛池模板: 黑河市| 阜康市| 南漳县| 丰顺县| 邵阳市| 庆元县| 肥乡县| 阆中市| 临泉县| 旬邑县| 嘉义县| 洪泽县| 名山县| 霞浦县| 红河县| 舟曲县| 无锡市| 临湘市| 绥宁县| 宜州市| 灵武市| 凤翔县| 台南县| 泾阳县| 噶尔县| 茶陵县| 叶城县| 扎赉特旗| 铜鼓县| 纳雍县| 曲周县| 施秉县| 苍梧县| 攀枝花市| 武胜县| 朝阳县| 望奎县| 定远县| 湖口县| 蓝山县| 靖西县|