ReactJS-The Beginner Master Class
  • React In the Beginning
    • Lesson 1 - Demo: Build a Simple React App - Fast
    • Lesson 2 - HTML Review
    • Lesson 3 - CSS Review
    • Lesson 4 - Modern JavaScript (JSX) Patterns
    • Lesson 5 - Set up Dev Environment
    • Hands-on Practice
  • React Fundamentals
    • Lesson 1 - Understanding Old vs New Way of Building Web Apps - SPAs
    • Lesson 2 - Motivation for Using React as the Solution to Vanilla JS
    • Lesson 3 - What is ReactJS - How it Works
    • React Code Along from Scratch
    • Lesson 4 - Create and Run a React Project with Vite - Full Overview
    • Lesson 5 - Create Hook by State Management in React
    • Lesson 6 - React Project File and Folder Walkthrough
    • Lesson 7 - JSX and How React Treats the DOM & JSX Compilation(by Babeljs) - Overview
    • Lesson 8 - Understanding the Main Files - App.jsx and main.jsx
    • Lesson 9 - Props and One-Way Data Flow - Overview
    • Lesson 10 - Google Bookshelf App - Ver 1.0
    • Hands-on Practice I
    • Hands-on Practice II
  • React State and Styling
    • Lesson 1 - Pulling Book Data from a Different Data File
    • Lesson 2 - Overview of How State Works in React
    • Lesson 3 - RandomQuote App
    • Lesson 4 - Lifting State Up - React Pattern Overview
    • Hands-On - Simple Counter
  • Forms and Interactivity - Grocery List App
    • Lesson 1 - Setup a Simple Form and Input
    • Lesson 2 - Build Form Profile App Using Multi-input Form Data
    • Hands-on : Build a Grocery List App
  • Connecting to the Backend - Consuming APIs - UseEffect Hook
    • Lesson 1 - Connecting to the Back End - Understanding Side Effects, Hooks and useEffect - Overview
    • Lesson 2 - Fetching Data from the Backend the Right Way with useEffect Hook
    • Lesson 3 - Setting Up Loading State
    • Hands-on :Use Dependency Array and Adding Values that Control Side Effects
  • Solo Project 1
  • RESTful APIs :Build a BookSearch App -Ver 2.0
    • Lesson 1: Build and test RESTful APIs with Postman
    • Lesson 2 - BookShelf App Structure
    • Lesson 3 - Create NavBar.jsx Component
    • Lesson 4 - Create Footer Component
    • Lesson 5 - Create BookList.jsx Component
    • Lesson 6 - Create BookCard.jsx Component
    • Lesson 7 - Creating Custom Hooks - useBooks and api-client
    • Lesson 8 - Controlling Network Activities in React with AbortController
    • Lesson 9 - Show Book Details in a Modal - Working
    • Lesson 10 - Bookshelf App Summary
  • Multi-Page Applications (MPAs)
    • Build a Multi-Page React Application
    • Multi-Page React Application
    • Hands-on Practice
  • Backend Frameworks-NEXT.JS
    • Migrating from React to Next.js
    • Lesson 1: Key Concepts of NodeJS and Express for Backend Web Development
    • Lesson 2: How to set up a new Next.js project
    • Lesson 3: How to create Layouts and Pages
    • Hands-on Practice 1
    • Hands on Practice 2
      • New Project & Folder Structure
      • File-Based Routing
      • Server vs Client Components & Router Hooks
      • Start On The Navbar
      • Navbar Links, Dropdowns & React Icons
      • Active Links & Conditional Rendering
      • Homepage Components
      • Properties Page
      • Property Card Dynamic Data
      • Home Property Listings
      • Custom Not Found & Loading Pages
  • Git and GitHubs
    • Git Installation
    • Git Commands
    • GitHub Repository
    • Hands-on Practice
  • Database in Application
    • React Supabase CRUD
    • Hands-on: Note Taking App
  • NoSQL Database
    • Installing MongoDB Community Edition
    • System Env Path Setting
    • How to use MongoDB Shell
    • How to Connect and Use Mongosh in VS Code via MongoDB Extension
    • MongoDB Guide
  • Solo Project 2
  • Deployment and Web Hosting
    • Lesson 1. React+Vite+TS+Shadcn Project
    • Lesson 2. Deploying a React Vite App to Vercel from Vercel CLI
    • Lesson 3 Connecting to GitHub Repo and Automate Deployment
  • Solo Project 3
  • Final Term Project
    • Level 1 Team Project
    • Level 1 Team Project
    • Level 1 Team Project
    • Level 1 Team Project
    • Level 2 Team Project
    • Level 2 Team Project
    • Level 3 Team Project
    • Level 3 Team Project
Powered by GitBook
On this page
  • Overview
  • Old Approach
  • Description of the Old Approach
  • Inefficiencies of the Old Approach
  • In Summary:
  • Modern Approach -SPA
  • Description of the Modern Approach (SPA)
  • Why the Modern Approach is Efficient
  • In Summary:
  1. React Fundamentals

Lesson 1 - Understanding Old vs New Way of Building Web Apps - SPAs

PreviousReact FundamentalsNextLesson 2 - Motivation for Using React as the Solution to Vanilla JS

Last updated 5 months ago

Overview

Old Approach

Description of the Old Approach

The image illustrates a traditional server-side rendering (SSR) model for web development. In this approach:

  1. Server-Side Rendering: Whenever a user requests a web page, the server generates the entire HTML, CSS, and JavaScript for that page and sends it to the client (browser).

  2. Client-Side Interaction: If the user interacts with the page (e.g., clicks a button, submits a form), the browser sends a request back to the server.

  3. Server-Side Processing and Rendering: The server receives the request, processes it (e.g., updates data, performs calculations), and then renders a new, complete HTML page to send back to the client.

  4. Page Reload: The client receives the new HTML page and replaces the entire page content, leading to a full page reload.

Inefficiencies of the Old Approach

  1. Unnecessary Data Transfer: With each interaction, the server sends the entire HTML page, even if only a small part of the page needs to be updated. This leads to redundant data transfer and increased network traffic.

  2. Slow User Experience: Page reloads create a noticeable delay, interrupting the user flow and making the application feel sluggish.

  3. Performance Bottleneck: As the application grows in complexity, the server's workload increases with each interaction, potentially leading to performance bottlenecks and slower response times.

  4. Poor User Experience: The constant page reloads can be jarring for users, especially on slower connections.

In Summary:

The old approach, while functional, is inefficient due to its reliance on full page reloads for every interaction. This results in unnecessary data transfer, slow user experience, and potential performance issues.

Let me know if you'd like to explore more about modern approaches like Single-Page Applications (SPAs) that address these inefficiencies!

Modern Approach -SPA

Description of the Modern Approach (SPA)

In a Single-Page Application (SPA), the core idea is to load a single HTML page initially, and then dynamically update portions of that page as the user interacts with the application. Here's a breakdown:

  1. Initial Page Load: The server sends an initial HTML page with the necessary JavaScript and CSS files. This page contains the basic structure of the application.

  2. Client-Side Rendering: The JavaScript code takes over and handles most of the rendering and interaction. It uses APIs to fetch data from the server in a lightweight format like JSON.

  3. Dynamic Updates: When the user interacts with the application (e.g., clicks a button, submits a form), the JavaScript code makes AJAX requests to the server. The server responds with the necessary data, and the JavaScript updates the DOM (Document Object Model) to reflect the changes, without reloading the entire page.

  4. DOM Manipulation: JavaScript directly manipulates the HTML elements on the page to update content, display new elements, or change their styles. This allows for smooth and interactive user experiences.

Why the Modern Approach is Efficient

  1. Reduced Data Transfer: Instead of transferring entire HTML pages, only the necessary data (often in JSON format) is exchanged between the client and server. This significantly reduces network traffic.

  2. Faster Interactions: Since the entire page doesn't reload, interactions are much faster and more responsive. The user experience is smoother and more fluid.

  3. Improved Performance: By offloading rendering and interaction logic to the client, the server's load is reduced, leading to better overall performance and scalability.

  4. Enhanced User Experience: SPAs offer a more engaging and interactive experience, as the application feels more like a native app rather than a traditional web page.

  5. Backend Responsibility: The backend focuses on providing data and handling business logic, while the frontend handles presentation and user interaction. This clear separation of concerns leads to better maintainability and scalability.

In Summary:

The modern SPA approach offers several advantages over traditional server-side rendering. By minimizing data transfer, reducing page reloads, and leveraging client-side rendering, SPAs provide a faster, more responsive, and engaging user experience.