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

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.

主站蜘蛛池模板: 海城市| 遂昌县| 米泉市| 永丰县| 林西县| 马龙县| 上栗县| 陕西省| 鞍山市| 彝良县| 新余市| 蓬安县| 兰坪| 施秉县| 北票市| 莒南县| 三江| 溧水县| 沅江市| 乡城县| 环江| 广安市| 文昌市| 昔阳县| 台中市| 宁蒗| 时尚| 康保县| 锡林浩特市| 进贤县| 依安县| 怀柔区| 云浮市| 东兴市| 冀州市| 东莞市| 泰安市| 吴桥县| 高清| 东乡县| 平乐县|