Components in React
In React, components are JavaScript functions or classes that return a piece of UI. They can be divided into two main categories: functional components and class components.
- Functional Components: These are simple JavaScript functions that accept props as input and return JSX (JavaScript XML) to describe the UI.
- Class Components: These are ES6 classes that extend the
React.Component
class. They have arender()
method that returns the UI and can have additional lifecycle methods and states.
How does a Pure Component Differ from a Regular Component ?
In React, components are the building blocks of user interfaces. They encapsulate the UI logic and render the UI elements based on the input data. React offers different types of components, including regular components and Pure Components.
Table of Content
- Components in React
- Regular Components
- Benefits of Regular Components
- When to use Regular Components
- Pure Component
- Benefits of Pure Components
- When to use Pure Components
- Difference
- Conclusion
Contact Us