Class Component :
Class Components are those in which we extend the React. Component and there is a render function that returns a react element
Example:
class Home extends React. Component {
render() {
return <p> here is a class paragraph </p>
}
There are also some lifecycle methods used in Class Component
1) ComponentDidMount
2) ComponentDidUpdate
3) ComponentWillUnmount
Functional Component :
Functional Component is a Simple Javascript Function that takes props as an Argument and Return a React Element
Example:
function Home(props){
return <p>this is my home functional component</p>
}
There are also some lifecycle methods (Hooks) used in Functional Component
1) UseEffect
2) UseState
3) UseReducer
4) UseCallBack
5) UseMemo
0 Comments