Yogesh Chauhan's Blog

What is React? Learn the basics

in React on April 21, 2021

React is a JavaScript library for building user interfaces. It is developed by Facebook.

React is a library and not a framework.

To learn and develop stuff with React, you need to understand HTML, CSS, JavaScript ES6, HTML DOM and some basic installation knowledge if npm packages, node etc. I am confident that even if you don’t know a whole lot about those topics, you can always learn by doing. Not every one who develops in React know all things about everything. All you need to know is just major concepts.

Here’s the React repo on GitHub if you want to check that out.

React is really helpful in creating User Interfaces (UIs) really easily. I try to compare it with Java and even Swift since I have worked in both for a while and if you’re a MVC kinda person then think of React as view in that structure.

Few advantages as per their official website

React automatically updates the view or the output of your code. So, even if you make a small change in your code, the whole view gets rewritten in seconds. Unlike programming languages like PHP or even simple HTML requires a refresh to update the view.

React makes the debugging easy — well at least a bit easier since the view gets updated constantly.

One of the biggest advantage is it divides the application in small components. Each component has its own state. Eventually, it compiles everything to make the complex app but for developers it’s easier to manage everything in smaller pieces.

By doing so React separates concerns with loosely coupled units called “components” that contain both.

In computer science, separation of concerns (SoC) is a design principle for separating a computer program into distinct sections such that each section addresses a separate concern.

All of those small code components are easily reusable which reduces the amount of code we write. Then it becomes a case of utilizing different components.

I a done with boring theory. Let’s build something.

First App

Make sure you have node and npm installed on your computer. You’re going to need it to run the following commands.

If you’re in a rush, just run this command. I will go though everything in details later on.

npx create-react-app first-react-app

// or use the following command
npm init react-app first-react-app

// if you're using yarn as a package manager than use this
yarn create react-app first-react-app

If everything goes fine, just go inside the project by using this command:

cd first-react-app

Finally, start the app.

npm start

// or

yarn start

If you’re using Mac, it’ll ask for your permission for terminal app to open the app in Chrome. Approve it and you’ll see your app running in browser window just like this:

Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How to Recognize an Array in JavaScript?JavaScriptHow to Use Aggregate Functions (MIN, MAX, SUM, AVG, COUNT) to Summarize Data in SQL?SQL/MySQLHow to add and remove list items using JavaScript?JavaScriptThe actual difference between indexOf() and search() in JavaScriptJavaScriptLearn to Make a Simple Contact Us Form using PHP and PDO-MySQLPHPFew more :nth-child examples in CSSCSS