Components
In this blog, I've tried to explain React Components.
Components mean we can create pieces of our code, e.g header, navbar, etc. We can use one component in another component. Components are reusable.
Types of Components
There are 2 types of components.
Functional component
Class component
Difference between Functional component and Class component.
Functional Components
Functional Components are known as state-less components, but after react version 16.8 we can handle the state using hooks and we can also implement the logic.
There is no render method used in functional components.
We can not use lifecycle methods in functional components.
In functional component receives props as parameters in the function definition.
After hooks concept function component maintains its own private data with the help of hooks.
Class Components
Class components are known as "smart" or "stateful" components because they implement logic and state.
render() method used in the class component.
We use lifecycle methods in the class component. (e.g componentDidMount, componentDidUpdate, etc.)
In class component we access the props like this.props.
Class components maintain their own private data with the help of state.