dots Created with Sketch.
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:

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jul 22 Is there a CSS parent selector? #Jul 22 Difference between :where and :is in CSS #Jul 22 Does :is() pseudo selector hint at CSS preprocessing in the future? #Jul 22 Control Scrolling with CSS Scroll Snap #Jul 21 Control rendering using CSS content-visibility property #Jul 21 How to use @supports rule in CSS?
You might also like these
IN Operator in PostgreSQLPostgresHow to use Context in React?ReactHow to refresh a page using PHP at regularly occurring intervals?PHPHow to hide and show menu on scroll using JavaScript and CSS?CSSThe difference between Class declarations and Class expressions in JavaScriptJavaScriptHow to verify your domain in Google Console with a TXT record?Miscellaneous