Part - 1 . React-JS

Part - 1 . React-JS

·

4 min read

Hello All

Starting My React Journey: Why and How I’m Diving Into Frontend Development

I will keep writing about my learning journey like whatever I will learn which can be included

  • Notes

  • Shortcodes ( snippets )

  • Roadmap that i will follow

  • Youtube video channels.

  • and most important what is real use of particular features of react js

So what is ReactJS?

React is a JavaScript library created by Facebook that makes building user interfaces (UIs) for websites and apps easier.

When it comes to ReactJS there are some terminologies the words are linked to that

  1. Babel compiler

  2. React fiber

  3. DOM vs Virtual DOM

I will write about what I got to know and what I understood.

1 ) Babel Compiler

Babel is a JavaScript compiler that translates modern JavaScript and JSX into browser-compatible code because browsers don’t understand JSX. Babel transforms JSX into plain JavaScript that React can interpret

2 ) React Fiber

React Fiber is the re-implementation of the core algorithm for the Reacts rendering engine. It is designed to improve how React updates the Virtual DOM and efficiently manages updates to the real DOM.

Before React Fiber, React used an older algorithm called the "Reconciliation algorithm", which was synchronous and blocked the UI from being responsive. With Fiber, React can now break rendering work into units, which can be paused and resumed, leading to smoother user interactions. make it simple but shorter

3 ) Real DOM VS VDOM

  • Real DOM is the actual structure represented in the User Interface

  • A virtual DOM object is the same as a real DOM object, except that it is a Lightweight copy.

  • Virtual DOM is a concept used by modern frameworks like React to optimize the rendering process

How Does the Virtual DOM Work?

The Virtual DOM creates an in-memory representation of the Real DOM, allowing developers to make changes without directly affecting the actual page. Here’s how it works:

  1. Virtual DOM Creation: When the application state changes, the Virtual DOM creates a new virtual tree.

  2. Diffing Algorithm: The new Virtual DOM tree is compared with the previous version, and the differences (known as “diffs”) are calculated.

  3. Batch Updates: Instead of updating the entire Real DOM, only the nodes that have changed are updated, leading to faster rendering.

Table format difference

Real DOMVirtual DOM
Real DOM represents the actual structure of the webpage.Virtual DOM represents the virtual/memory representation of the Webpage.
DOM manipulation is very expensiveDOM manipulation is very easy
There is too much memory wastageNo memory wastage
It updates SlowIt updates fast
It can directly update HTMLIt can’t update HTML directly
Creates a new DOM if the element updates.Update the JSX if the element update
It allows us to directly target any specific
node (HTML element)It can produce about 200,000 Virtual DOM
Nodes / Second.
It represents the Ul of your applicationIt is only a virtual representation of the DOM

When it comes to setup of react JS

first you should have NodeJS installed in your Machine.

You might be wondering why it’s needed.

Because

  • Node.js allows you to use npm (Node Package Manager) or yarn to manage the libraries and dependencies required for React projects.

  • React projects often use build tools like Webpack, Babel, or other bundlers to transpile JSX and modern JavaScript syntax into code that browsers can understand. These tools are typically written in JavaScript and run in a Node.js environment.

Node.js is essential for a smooth and modern React development experience, enabling tools and workflows that make it easier to build, test, and deploy React apps efficiently.

you can download from this link

For step-by-step installation process you can go throgh this Youtube VIdeo

When it comes to styling you can go With Vanila css also but Tailwindcss is better choice for CSS

You can use vanilla CSS for styling, which gives you complete control over your styles. However, Tailwind CSS is often considered a better choice for modern development due to its efficiency and utility-first approach.

AspectVanilla CSSTailwind CSS
CustomizationFull control over styles from scratch.Predefined utility classes, customizable via configuration.
EfficiencyWriting styles can be repetitive and time-consuming.Faster styling with reusable, pre-built utility classes.
ScalabilityManaging large stylesheets becomes challenging in big projects.Ensures consistency and scalability with utility-first design.
  • A step-by-step process for installation of ReactJS with the help of Tailwindcss Documentation

TailwindCSS Document

  • or else you can refer this video as well

Youtube Video