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

Hello, World!

Now that our environment has been set up to support JSX, we can dive into the most basic example: generating a div element.

This is how you would create a div element with React's createElement function:

  React.createElement('div')

And this is the JSX for creating a div element:

  <div />

It looks similar to regular HTML.

The big difference is that we are writing the markup inside a .js file, but it is important to note that JSX is only syntactic sugar, and it gets transpiled into JavaScript before being executed in the browser. 

In fact, our <div /> element is translated into React.createElement('div') when we run Babel, which is something we should always keep in mind when we write our templates.

主站蜘蛛池模板: 丹江口市| 新乡市| 博爱县| 靖边县| 蚌埠市| 乌海市| 古交市| 永吉县| 深水埗区| 通海县| 炎陵县| 大安市| 双柏县| 文成县| 巴南区| 黄大仙区| 东阿县| 加查县| 营口市| 仁怀市| 古交市| 牙克石市| 贞丰县| 云林县| 平湖市| 利辛县| 淄博市| 德惠市| 吴江市| 涟源市| 江油市| 西盟| 望奎县| 五河县| 将乐县| 安阳县| 东乡县| 麟游县| 玛多县| 铜川市| 阳山县|