Appendix

1. Getting Started with React

Activity 1.01: Design a React Component

Solution:

  1. Verify that Node.js and Create React App are installed on your machine:

    $ node --version

    Output:

    V12.6.0

    $ npx create-react-app --version

    Output:

    2.1.1

  2. Create your project, called buystuff, via the Create React App CLI:

    $ npx create-react-app buystuff

  3. Delete all the unnecessary files for our project.

    Delete App.css, delete the contents of App.js except for the import and export statements, and delete logo.svg.

  4. Build the App React component as a class component but leave it blank.
  5. In App.js, change the import statement at the top:

    import React, {Component} from "react";

  6. Then add the following component definition:

    class App extends Component {

      render() {

        return ...

Get The React Workshop now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.