A single-page application (SPA) is a web application or website that loads a single HTML page and dynamically updates the page as the user interacts with the application. SPAs are different from traditional web applications, which load a new HTML page every time the user clicks a link. This means that SPAs can provide a more responsive and fluid user experience, as well as faster loading times.

React Components

There are two types of components:

  1. Class Based Components
  2. Function Based Components

Class Based Components

Before making class based component we need to inherit functions from React.Component and this can be done with extends, like this:

class Cat extends React.Component {
  render() {
    return <h1>Meow</h1>;
  }
}

it also requires a render method which returns HTML.

Function Based Components

In function it's simpler, we just need to return the HTML, like this:

function Cat() {
  return <h1>Meow</h1>;
}

Note: Component's name must start with uppercase letter.

Differences Between Class Components and Function Components in React

  1. Syntax and Structure
  2. State Management
  3. Lifecycle Methods