React some of the basics that must be known

Source: Internet
Author: User

React originated in Facebook's internal project because the company was dissatisfied with all the JavaScript MVC frameworks on the market and decided to write a set of Web sites that would be used to erect Instagram. After doing it, found that this set of things very useful, in May 2013, open source. Because React's design ideas are extremely unique, revolutionary and innovative, the code logic is simple. Therefore, more and more people are beginning to pay attention to and use, think it may be the mainstream tool of WEB development in the future.

1. JSX syntax

React uses JSX instead of regular JavaScript. JSX is a JavaScript syntax extension that looks much like XML.

Reactdom.render (<div>

We can nest multiple HTML tags in the above code, we need to wrap it with a DIV element (with only one outermost tag), the P element in the instance adds a custom attribute Data-myattribute, and the addition of the custom attribute requires the use of the data- prefix.

2, the application of components

Building components through React makes the code easier to reuse and can be used well in the development of large projects. The core of react is the component, the so-called component, which is a packaged, individually functional UI component. React recommends a component-based rethinking of the UI composition, defining each module that is functionally independent on the UI as a component, and then building the overall UI by composing or nesting the small components into large components. For example, Facebook's instagram.com entire site was developed using react, and the entire page was a large component that contained a large number of other components nested, and it was interesting to see the code behind it. Let's look at an example of a component:

var hellomessage = React.createclass ({        render:function () {          return 

The React.createclass method is used to generate a component class HelloMessage.

 

React some basics that you must know

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.