DEV Community

Diomedes Lajara
Diomedes Lajara

Posted on

1 2

React Classes vs Funcomps

https://thepracticaldev.s3.amazonaws.com/i/6q6a5bxfcd67920xaru6.png

To write a Functional or to write a Class based component.

One way to decide whether a component will be a class or functional component is to think of what will go inside the component. If it as a simple component that returns some jsx with props and no logic. This is a Functional component that will only render things to the DOM, others call it a dummy component.

Class based component are easier to organize
Can use State object to make changes and interactions based on the user inputsThese components also handle and understands lifecycle events. Lifecycles are stages of an application. For example loading screens.

Rules for Class components
Must be a javascript class
Must externt (subclass) React.Component
Must define a ‘render’ method that returns some jsx

justnotes written around this date

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay