React is built around the concept of components. This is in contrast to frameworks like Angular and Ember, which use two-way data bindings to update the HTML of the page. In my opinion React is easier to learn than Angular and Ember – it is much smaller and plays nicely with jQuery and other frameworks. It is also extremely fast, because it uses a virtual DOM, and syncs only the changed parts with the underlying page.
How to use?
The ReactJS library can also be used directly from the Facebook CDN to increase the performance of the page load by including the link below in header tag:
Create a helloworld.html file with the following contents:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
The primary type in React is the ReactElement. It has four properties: type, props, key and ref. It has no methods and nothing on the prototype. We can create a element through
To render a new tree into the DOM, we create
ReactElements and pass them to
React.render along with a regular DOM Element.
In codes above we create a
h1 element in
App component and render it in body DOM.
Hello World - Separate File
Create a helloworld.js file with the following contents:
1 2 3 4 5 6 7
And update HTML file as below:
1 2 3 4 5 6 7 8 9 10 11
So far so good, That’s it!!! See ya!!! :)