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
Top comments (0)