Subscribe via RSS Feed

Basic Introduction to React.js

May 11, 2015 0 Comments

The aim of this article is to make a basic introduction to react.js. Today React.js is gaining much more popularity in Front-end Web Developer world. Asics Pas Cher

As we understand, React.js is a front-end developement framework, created and maintained by facebook for their production application. Fjallraven Kanken Sverige The framework focuses on UI and expect to handle the backend by WEB Apis. nike air max 2017 goedkoop React.js implements One way data-flow.

We are learning React.js and will try to go through all the concepts of React.js step-by-step. Here is a first Example of React.js Code, which will simply print “Hello React World” on the Html Page.

reactex

Basic Example without JSX

[javascript] <!DOCTYPE html> <html> <head> <meta http-equiv=’Content-type’ content=’text/html; charset=utf-8′> <title>Basic Example</title> <script src="react.js"></script> </head> <body> <h1>Basic Example</h1> <div id="container"> <script src="react.js"></script> <script> var ExampleApplication = React.createClass({ render :function() { var message = "Hello React World"; return React.DOM.b(null, message); } }); React.renderComponent( ExampleApplication(), document.getElementById(‘container’) ); </script> </body> </html> [/javascript]

We assume here, react.js is in our application root folder. No other dependencies are there in this code. What – the code is doing? It simply prints some text in the web page.
React uses a specialized version of javascript, which is called jsx. These jsx codes are needed to be complied to produce pure javascript. To simplify this conversion, JSXTransformer.js is needed to be included in the Application web page. adidas sale uk But for now, we have not used this feature and simply made a javascript code to show the example with react.js. nike air max We will see the use of JSXTransformer.js in our next articles.

In the above code, the ExampleApplication is represented as a React Class, which is having a pre-defined render method. This render method is responsible to update the view of the React Component. Here it is attaching a “hello world” king of message to the React DOM.

Now with the React.renderComponent, it is taking the class ExampleApplication and the respective div container – where the react component will be rendered. So finally it is showing the Hello React World.

We will write step-by-step article to understand react.js features. Meanwhile, for better understanding react.js, we should refer to facebook tutorial.

If you find this article helpful, you can connect us in Google+ and Twitter.

Leave a Reply

You must be logged in to post a comment.