Skip to main content

What is react Js?

React Js:

Image result for react js image 


Let me explain this with a practical example.
Imagine your favourite celebrity posting a photograph on Facebook. Now you go and like the image and then you suddenly see that lets check out the comments too. Now while you are browsing over comments you see that likes count increased by count 100 since you liked the picture. Yes and there was no reload of the page, just somehow magically the count changed. This magic my friend is react.js.
So to explain it better, imagine your web page. Again I will take example of Facebook since everybody uses it and common they created react.js :D . So billions of posts, so much traffic, millions like count. How do they manage all that a blazing speed. To do that they come up a library called react.js
Imagine a post on facebook. Now this post which is a container consists of multiple small parts like likes,comments,share,commentbox called components. So yes with react you page can be broken down into components. Now you must be wondering why do we do this, we already have awesome frameworks on front end? Well if you dont you are certainly going to be amused now.
HOW IT WORKS:-
Entire web is based on html. It all started with a simple HTML code and people went wohoo in the 90’s . Next came Javascript in 1996 with ways to interact with the HTML DOM(Document Object Model). After that was established came Jquery to change the contents of the HTML DOM. Next after that in 2009 came Angular.js as the daddy of front end frameworks which gave a full fledged option to create a strong frontend. Now if you see all these work on HTML code i.e you change HTML on basis of javascript(jquery, angular etc.). Now Javascript is much more powerful than HTML, Facebook considered this fact and decided to create the HTML itself from Javascript( dynamic content, if you know AJAX you should be able to relate to it) for which they created react.js. So to sum it up react.js creates your html from you javascript .
Now you know about components and how they work. You know react.js creates html from Javascript. But, reactjs itself is not written in vanilla javascript. React.js is written in something JSX(Java script XML). But HTML is created from Javascript right? So how do we get that JS from JSX. For this we use transpiler called Babel. Babel converts your JSX to JS which you can put in your html to create content dynamically.
WHAT MAKES IT FAST:
React has a concept of Virtual DOM. So say you html has this transpiled generated output javascript which creates your html. Now say whenever anything is changed in a particular component that component changes. Now these changes are not pushed to the DOM directly, but instead it is pushed to something called VirtualDOM. Now at this point there is a diff which occurs between VirtualDOM and real HTML DOM and changes are pushed to the realDOM. This is what makes it fast. Now trying linking to example I shared at the beginning of the answer. It should be clear now.
BENEFITS:
  1. Single Page Application.
  2. Entire page remains same but only few components change.
  3. Code is easy to scale and maintain.
  4. More functionalities as HTML is created from JS
  5. Isomorphic Rendering(Server side rendering)
  6. Blazing speed
Text from :Harkirat saluja from quora.

Comments

Popular posts from this blog

how to install flutter in linux mint:

What is Flutter?        Flutter is Google’s portable UI toolkit for building beautiful, natively-compiled applications for mobile, web, and desktop from a single codebase.   And Flutter have Many characteristics and you can see here .  How to Install it in your Linux Machine? You can download the Flutter package here . Extract the file in a separate folder.  cd ~/development  tar xf ~/Downloads/flutter_linux_v1.5.4-hotfix.2-stable.tar.xz Add the flutter tool to your path:  export PATH="$PATH:`pwd`/flutter/bin" And enter the code   flutter precache to check the flutter installed. And Run Flutter Doctor By the command   flutter doctor to see any folder is missing for that. (From Flutter.dev) Android Setup: Download and install the android studio . Start Android Studio, and go through the ‘Android Studio Setup Wizard’. This installs the latest Android SDK, Android SDK Platform-Tools, and Android SDK Build-Tools, which are required by Flutter when

How to install wordpress in linux

WordPress is a powerful, free and open-source, highly pluggable and customizable CMS that is being used by millions around the world to run blogs and fully functional websites. It is easy to install and learn, especially for persons who do not have prior website design and development knowledge. Step 1: Install Apache Web Server    To install apache server follow the instructions below     $ sudo apt-get install apache2 apache2-utils       Now we need to check whether it is installed or not     Go to the browser and type localhost if it is shown like this then no problem your apache is installed successfully   NOTE: The default Apache root directory is /var/www/html all your files are stored in the directory. STEP 2: Install MYSQL Database Server:    Now we need to install the MYSQL Database Server by running this command    $ sudo apt-get install mysql-client mysql-server During the package installation, you will be prompted to set the  root  user passwo

How to install Blender 2.80 (beta) in Linux:

About Blender:        Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing and motion tracking, even video editing and game creation. How to install the beta version: Download the latest version of the blender from here  . It will download an tar.gz folder. Extract the folder . Jump into the folder   and click on the Blender named file it will direct to the latest version but don't click on the blender.desktop file. Then it will open the blender window like this.