What is component is react js ?
A Component is one of the core building blocks of React. Components helps us the break the whole UI into independent and small reusable pieces. This behavior of React components let allows us to think and develop each components independently
In other words, we can say that every application you will develop in React will be made up of pieces called components. Components make the task of building UIs much easier. You can see a UI broken down into multiple individual pieces called components and work on them independently and merge them all in a parent component which will be your final UI.
Components are classified into 2 types:-
1. Functional Components: - Functional components are simply JavaScript functions. We can create a functional component in React by writing a JavaScript function. The following code explains the basic syntax of a functional component.
const Functional_Component()=>
{
return <h1>This is Functional Component!</h1>;
}
2.Cl ass Components:- The class components are a little more complex than the functional components and also they are more featured way to define a React component. The class component of React are basically the ES6 classes that are extended from react. The following code explains the basic syntax for a class component.
ex-
class Class_Components extends React.Component
{
render()
{
return <h1>This is Class Components!</h1>;
}
}
React components are loaded with features. Components have props, state and their life-cycle methods. These features of the components make them very useful for building fast efficient and rich user-interface.