Subscribe to Youtube channel

Getting started with react JS step by step from scratch

 In this article we will be discussing hot to create react app from scratch. We will also discuss about the project structure of react app. React JS is an library but most people says its an framework. Its actually an library by using it we can develop robust applications.

 


 

For react app we need to have install Node Js on development machine. To download Node JS you can visit below link and install it on your machine.

https://nodejs.org/en/download/ 


Node JS download  
I recommend you to always download LTS (Long term support) executable versions only.
 
Now we have downloaded and installed the node JS, its time to download and install the code editor to manage your code efficiently. I would recommend you that you can go with the Visual studio code. following is the link to download the visual studio code.
 

vs code download link

Now we have downloaded and installed visual studio code as well as Node JS. Lets launch the visual studio code, go to menu bar and click on Terminal option >>  New Terminal as shown in below figure, this will open the power-shell terminal at bottom of vs code ui. 
 
This power shell terminal helps you run the node/react commands while you are coding in single window, this is the beauty of the Visual studio code editor.

New Terminal 1
New Terminal 2

Now we will check the version of node installed in the machine by entering the following command in power shell terminal. 

 node -v  

 you will get the following output, in your case version of node might be different.

node version


Then we will also check the npm version installed in the machine by entering the following command in power shell terminal. 

 npm -v  

you will get the following output, in your case version of npm might be different.

npm version

Now we need to go to the directory where you want to create your react application by using cd command as shown in below figure.

directory

Now its time to create our new react application. Now enter below command to create react application in my case the app name is "react-example". The command will take some time to create the app hence sit back and relax, app will create in minute or two.

 npx create-react-app react-example  
react app command

React app Installed

Now as per above image the react app is created and ready for use. Now we need to open the react app files in visual studio code for that navigate to menu bar of vs code Click on File >>Open Folder option and select your react application folder as shown in below figure.

open folder

 once click on open folder button you can see the folders and files in left pane of the vs code as shown below figure.

 

app details

project structure

Public: The public folder holds your static files of your projects such as images, icon, html, fonts, svg files etc

Src: The scr folder holds all your source code file such as js, css etc

Package.JSON file: This file holds all the information about npm packages installed in your application 

  

Now lets run the application, for that you need to run following command in power shell terminal.  


 npm start  

the above command will create the listener and open the browser with running application as shown in below figures.

react output

react output 1


that's it you have successfully created your first react app successfully.




Comments

Popular posts from this blog

Root your Gingerbread 2.3.4 android Mobile Phone

Implement Logging in CSV file using Nlog in .net core MVC application- part 2

Disable backspace key using Jquery

Restore the lost focus of Auto post back controls in asp.net update Panel control

Devexpress Datebox date formatting in angular 6 with example

Implement Nlog in .Net core MVC application part 1

Angular User Session Timeout example step by step

How to Import CSV File and bind csv file data to gridview in asp.net using c#

Add Comma automatically while entering amounts in textbox using Javascript