Skip to content
doubtly

2 answers

The two types are function components and class components.

1. Function component: a JavaScript function that returns JSX. With Hooks (useState, useEffect) it can have state and side effects. This is the recommended style today.

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

2. Class component: an ES6 class that extends React.Component and has a render() method. It uses this.state, this.setState() and lifecycle methods like componentDidMount.

class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}
Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.