1. Getting Started with React
Activity 1.01: Design a React Component
Solution:
- 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
- Create your project, called
buystuff
, via the Create React App CLI:$ npx create-react-app buystuff
- Delete all the unnecessary files for our project.
Delete
App.css
, delete the contents ofApp.js
except for the import and export statements, and deletelogo.svg
. - Build the
App
React component as a class component but leave it blank. - In
App.js
, change the import statement at the top:import React, {Component} from "react";
- Then add the following component definition:
class App extends Component { render() { return <div className="App"/>; } }
- Build the
Header
React component as a functional component insideApp.js
. Its only prop should betitle
, which contains...