Components are usually a piece of UI(User Interface).Components are also called as building block of react app.
There are two major components in react.js:
1)Functional Components- They don't have no state of their own and only contain render methods and it also called as stateless components.
function Greeting(props) {
return <h1>Welcome to {props.name}</h1>;
}
2)Class Components-It can hold and manage their own state and also have their own render methods to return JSX.It also have state ,so it is also called stateful components.
class Greeting extends React.Component {
render() {
return <h1>Welcome to {this.props.name}</h1>;
}
}