Category Archives: React.js Tutorial

React.js Tutorial

ReactJS Hello World Application

ReactJS Hello World Application

We will start learning ReactJS application development by creating a “Hello world!” application. The “Hello world!” program is a simple yet complete example for beginners that illustrates the basics of ReactJS. The “Hello world!” application will also gives you a way to test systems and development environment. This tutorial will guide you through writing a basic “Hello World!” application in ReactJS.

In this tutorial we will use the same application that we created in ReatcJS Installation.

Creating ReactJS Hello World Component

In this example we will create a component that will print “Hello World!” string.

Step 1:- Let’s open src/App.js, that we created in helloworld application.

reactjs-helloworld-1

 

Step 2:- Now, delete the existing code and put the following code in it and save it-

src/App.js will now look like this –

reactjs-helloworld-2

 

Here, the first statement is used to include the react module, next we are creating a “App” Component by creating a “App” class that extends the Component class.

Inside of “App” class we have created a render method which is a part of React.Component class, it return a “W3Adda – Hello World!” message enclosed in <h1></h1> tag.

Next, we have following statement –

here, we are App component to be mounted to a DOM Element that we have available in public/index.html file –

reactjs-helloworld-4

Step 3:- Let’s open the terminal again, change directory to your project folder and type the following command in order to run the server.

Step 4:- Now open the following URL in browser to view the output

http://localhost:3000

Step 5:- You will see the following screen.

reactjs-helloworld-3

 

 

ReactJS Installation

ReactJS Installation

In this article you will learn how to Setup React.js development environment Using Npm, Babel and Webpack. It is not required to use Babel and Webpack in order to used React, but to get most out of the features of ES6, JSX and bundling, we need them.

Installing Node and npm

In order to setup ReactJS development environment, you will need NodeJS and NPM installed, so if you don’t have it installed, check the following instruction to get it installed. If you’ve already have installed Node.js in your system, you can skip this part.

Step 1:- Download the Node.js from the official Node website, link given below –

Step 2:- Run the installer (the .msi file you downloaded in the previous step.)

Step 3:- Follow the installation wizard to install Node.js and npm.

Step 4:- Restart your computer. You will not be able to run Node.js until you start your computer again.

Setting Up a ReactJS Project

Step 1:- Install Create React App , easiest react installer with following command –

Step 2:- Let’s create a react using following command –

reactjs-installation-1

Step 3:- Now, switch to project directory –

reactjs-installation-2

Step 3:- Now, type the following command in order to run the server.

reactjs-installation-3

Step 4:- Now open the following URL in browser to view the output

http://localhost:3000

Step 5:- You will see the following screen.

reactjs-installation-4