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

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.

主站蜘蛛池模板: 五原县| 永靖县| 武宣县| 赣榆县| 视频| 闽清县| 台东市| 灵石县| 修武县| 英德市| 兰考县| 大庆市| 萨嘎县| 高雄县| 安乡县| 唐河县| 禄丰县| 开鲁县| 闽侯县| 永靖县| 万载县| 南川市| 丹寨县| 桐城市| 项城市| 阳朔县| 肃南| 右玉县| 崇文区| 会昌县| 甘德县| 广元市| 台南市| 冕宁县| 天等县| 庆云县| 洛宁县| 夹江县| 鹤山市| 米林县| 德保县|