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.jsexcept for the import and export statements, and deletelogo.svg. - Build the
AppReact 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
HeaderReact component as a functional component insideApp.js. Its only prop should betitle, which contains...