Skip to main content

Command Palette

Search for a command to run...

What are class components or ES6 classes?

Published
•2 min read
What are class components or ES6 classes?
R

19, Hustler.

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.



😫Thanks For Reading | Happy Reacting😓

More from this blog

R

RAHULISM - FrontEnd Web Developer

232 posts

18, Hustler.