DEV Community

A Ramesh
A Ramesh

Posted on

Getting Started with React: My Learning Journey So Far

React is one of the most popular JavaScript libraries used for building dynamic user interfaces. As a beginner in React, I started my journey by understanding its core concepts. In this blog, I’ll share what I’ve learn so far: React DOM, npn vs npx,jsx, Framework vs Library, and the difference between SPA and MPA.


What is React DOM?

ReactDOM is a package that provides DOM-specific methods to interact with the HTML document. It is used to render React components into the actual DOM.

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render();

ReactDOM acts as the bridge between React and the browser DOM.


NPM vs NPX

Both npm and npx are command-line tools that come with Node.js, but they are used differently.

NPM (Node Package Manager): Installs packages.

NPX (Node Package Execute): Runs packages without installing them globally.

Example:

npm install create-react-app — installs the package.

npx create-react-app my-app — runs it directly without installing.

Use npx when you want to execute a tool or package temporarily.


What is JSX?

JSX stands for JavaScript XML. It allows us to write HTML elements in JavaScript and place them in the DOM.

Example:

const element =

Hello, React!

;

JSX is not required in React, but it makes the code more readable and easier to write. Under the hood, JSX is compiled to React.createElement() calls.


Framework vs Library

Here’s a simple comparison to understand the difference:

Feature Framework Library

Control Calls your code You call it
Flexibility Less flexible More flexible
Examples Angular, Django React, jQuery

React is considered a library because it focuses only on the "view" layer. But with additional tools (like React Router, Redux), it behaves like a framework.


SPA vs MPA

Understanding the difference between SPA and MPA is important in web development.

SPA (Single Page Application):

Loads a single HTML file.

Content changes dynamically without refreshing the page.

Faster user experience.

Example: React applications.

MPA (Multi Page Application):

Each page is a separate HTML document.

Requires full page reload for navigation.

Example: Traditional websites (like blogs, e-commerce sites).

React is ideal for SPA development, offering seamless navigation and better performance.

Top comments (0)