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")
)

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.

Leave a Reply