Getting started with React

Getting started with React:

 React is an open-source, front-end JavaScript library for building user interfaces or UI components. Released in May 2013, React is the most loved JavaScript framework because of its extra simplicity and flexibility.

This tutorial will show you how to use React and build your first web application using it.

What is JSX?

Before we begin, you must know what JSX is, as React uses it to function properly.

JSX (JavaScript XML) is a JavaScript syntax extension that makes it easier to write and add HTML. A simple example is shown below.

var element = 

The quick brown fox jumps over the lazy dog


React doesn’t require JSX, but most people find it helpful as a visual aid when working with UI inside the JavaScript code. It also allows React to show more useful error and warning messages. We aren’t going to use JSX in this tutorial.


Because this tutorial is for beginners, we are going to start simple. We are only going to use two files:

  • index.html
  • index.js (or whatever you want it to be named)

Setting up the HTML file

First, we are going to set up the HTML file. All we need to do is create a basic webpage, create a 

 element inside of the  element, and load the React library. We are going to use a CDN, so we don’t have to download the full library.

The versions above are meant for development, and not for production. Minified and optimized production versions of React are also available:

For this tutorial, we are going to use the development version.

The HTML file should look like this:

Setting up the JS file

Now we are going to set up the JavaScript file. The simplest React example looks like this:


Hello, world!

, document.getElementById('root') );

Here is the same example, but without JSX:

  React.createElement('h1', null, 'Hello, world!'),

Add the example without JSX to the JavaScript file. Make sure to save your work!

Viewing the web app

Your website should look like this:

We can now view our newly created web app. Open index.html in a web browser, and you should see a heading that says “Hello, world!” on the page.


Congratulations! You have just learned to create your very first web app using React! I hope you enjoyed this tutorial!

from Tumblr

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s