React Class Components
Explore the foundation of React class components by learning how to create, render, and compose them. Understand the importance of extending React.Component to access lifecycle methods and state management. This lesson guides you through structuring components and building reusable, nested UI elements effectively.
We'll cover the following...
What are Components?
Components are simply the building blocks that make-up what a website looks like. For example, Facebook’s like button is a component. Let’s try to code up a component.
import React from 'react';
export default class App extends React.Component {
render() {
return (
<div> This is a component </div>
);
}
}
Explanation:
Line 1 of the index.js file imports the React library; this allows you to use all the functionality and features of React. Revisit the modules chapter if you want a refresher on how this works.
Line 3 of the app.js file creates a default export App class that inherits the React.Component class, ...