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

What is React?

I think the one-line description of React on its homepage (https://facebook.github.io/react) is brilliant:

A JavaScript library for building user interfaces.

It's a library for building user interfaces. This is perfect, because as it turns out, this is all we want most of the time. I think the best part about this description is everything that it leaves out. It's not a mega framework. It's not a full-stack solution that's going to handle everything from the database to real-time updates over web socket connections. We don't actually want most of these pre-packaged solutions, because in the end, they usually cause more problems than they solve. Facebook sure did listen to what we want.

React is just the view

React is generally thought of as the view layer in an application. You might have used a library such as Handlebars or jQuery in the past. Just like jQuery manipulates UI elements, or Handlebars templates are inserted onto the page, React components change what the user sees. The following diagram illustrates where React fits in our frontend code:

This is literally all there is to React—the core concept. Of course there will be subtle variations to this theme as we make our way through the book, but the flow is more or less the same. We have some application logic that generates some data. We want to render this data to the UI, so we pass it to a React component, which handles the job of getting the HTML into the page.

You may wonder what the big deal is, especially since at the surface, React appears to be yet another rendering technology. We'll touch on some of the key areas where React can simplify application development in the remaining sections of the chapter.

Note

Don't worry; we're almost through the introductory stuff. Awesome code examples are on the horizon!

主站蜘蛛池模板: 正镶白旗| 皮山县| 微山县| 绵竹市| 临邑县| 托克逊县| 安达市| 磐石市| 郴州市| 赣州市| 襄樊市| 牡丹江市| 林西县| 板桥市| 华池县| 谷城县| 永泰县| 江门市| 永胜县| 陕西省| 太保市| 红河县| 涡阳县| 无为县| 延庆县| 广安市| 曲沃县| 富宁县| 前郭尔| 双城市| 西峡县| 长岭县| 布拖县| 平陆县| 尚义县| 广丰县| 乐至县| 偏关县| 阿克苏市| 页游| 黄浦区|