In the last, we discussed the Functional Components. In this post, we will know about the class component or ES6 Classes.
Introš
Class components are ES6 classes. Class components optionally receive props as input ad renders JSX. It can also maintain the private internal state of a particular component.
Example:
class welcome extends Components{
render()
{
return <h1>Hey, {this.props.name}</h1>
}
}
The component should always start with capital letter and the props should never be modified.
Drawbacks ā
Class components are slight slower than their functional counterparts. The performance difference increases when the number of components in the app increases.
Class components involve a lot more coding on the programmer's side making them slightly more inefficient to use.
Related Posts
š«Thanks For Reading | Happy Reactingš“
Top comments (0)