Hello World in React

Posted on by By Nikhilesh, in Miscellaneous | 0

React is a view library by facebook. The easiest way to get started with it using jsfiddle. Here we will have a look at writing a simple Hello world in react.

The following code will render “Hello World!” inside h1 in div#main.

ReactDOM.render(
	<h1>Hello World!</h1>,
    document.getElementById("main")
)

 

[iframe width=”100%” height=”300″ src=”//jsfiddle.net/vkbansal/rhrr246L/embedded/” allowfullscreen=”allowfullscreen” frameborder=”0″]

The HTML like syntax you see is called JSX. It is just syntactic sugar for the following code.

ReactDOM.render(
    React.createElement(
        "h1",
        null,
        "Hello World!"
    ),
    document.getElementById("main")
);

JSX can be compiled to JS using tools like babel.

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments