function vs class components react code example

Example 1: class app extends component syntax

class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}

Example 2: difference between React.functioncomponent and React.component

import React from "react";

class ClassComponent extends React.Component {
 render() {
   return <h1>Hello, world</h1>;
 }
}

Example 3: difference between React.functioncomponent and React.component

import React from "react";
 
const FunctionalComponent = () => {
 return <h1>Hello, world</h1>;
};