React Class Components

All React websites are made up of components and this lesson gives an overview of how a basic React component is made.

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, ...