:: Day-1 of learning React ::

Today I've learned about what React is and how using React is more preferable than using any other framework.

What is React?

React js, or commonly known as React, is an open-source javascript library for building frontend or client-side interfaces, particularly for single-page applications or even complex web apps. It is developed and maintained by Meta and is is often referred to as a declarative library because in a declarative programming paradigm, developers specify what they want to achieve, rather than focusing on how to achieve it.
In React, you declare the desired state of the user interface based on the current state of your application data. You describe the UI components as functions of the application state, and React takes care of updating the DOM to match this declared state efficiently. Let us understand it with an illustration:
Suppose we are having an input field whose current state is empty. Now, once the user writes something in the placeholder section of the input field, the state changes accordingly, but in a virtual DOM maintained by React itself. This change is initial step and doesnot reflect on the actual DOM. React at the backstage performs a comaprision between its virtual DOM and the actual DOM tree, and out of which once it finds a component(s) that is different, it updates that particular component within the actual DOM. This happens so fast and the changes don't even require any page reload. The developer only specifies/declares the UI components with its state and a function to change it, then React takes responsibility to update it accordingly. Thus, it follows the declarative paradigm and is known as a declarative library.

Why React is prefered than other frameworks for building the UI of an application?

React.js is preferred over other frameworks for several reasons, although the choice ultimately depends on the specific requirements of a project and the preferences of the development team. Here are some reasons why React is often chosen over other frameworks:

  1. Component-Based Architecture: React's component-based architecture allows for the creation of reusable and independent UI components, promoting code reusability, maintainability, and scalability. Components encapsulate both the UI and behavior, making it easier to manage complex applications.

  2. Virtual DOM: React's use of a virtual DOM enables efficient updates to the user interface by only re-rendering the components that have changed. This leads to improved performance and a smoother user experience, especially in applications with dynamic content and frequent updates.

  3. JSX Syntax: JSX, a syntax extension for JavaScript used in React, allows developers to write HTML-like code directly within their JavaScript files. This makes it easier to create and visualize UI components, reducing the cognitive overhead of switching between different languages and files.

  4. Community and Ecosystem: React has a large and active community of developers, which has led to a rich ecosystem of libraries, tools, and resources to support web development. This includes libraries for state management (e.g., Redux, MobX), routing (e.g., React Router), and UI component libraries (e.g., Material-UI, Ant Design), among others.

  5. Flexibility and Scalability: React is highly flexible and can be used to build various types of applications, from single-page applications to server-side rendering and native mobile apps (with React Native). Its modular and composable nature allows developers to choose the best tools and libraries for their specific use case, making it suitable for projects of all sizes.

  6. React Hooks: Introduced in React 16.8, hooks provide a more elegant and functional way to manage state and side effects in functional components. Hooks simplify component logic and promote code reuse, leading to cleaner and more readable code.

  7. Performance: React's efficient rendering mechanism, combined with its use of virtual DOM and reconciliation algorithms, results in high performance and responsiveness. This is particularly important for applications with complex UIs or large datasets.

Conclusive points
Everything that has pros, comes with cons by default. Similarly, React is incomplete and since it was released by Meta, they only push those feature updates that are centric to Meta's implementation usage. They work up on features that are needed for their dev use and then they roll it out to the public, which is ofcourse a good practice but we only get those features that are suitable for Meta. And also it doesnot support Server-side-components and the usage of complex useEffect & useState logic can just increase the amount of code we write. To avoid this we can shift to any framework like- NextJS, Remix, VueJS, etc. who have their own advantages and can extend what React is incapable of.

Social handles:
LinkedIn
Github
Twitter