6. State and Props
Activity 6.01: Creating a Products App Page
Solution:
- Create the app's structure. By analyzing the data and its requirements, we can come up with the following structure for the app:
App   |-ProductListing     |-Product   |-Tags     |-Tag
The
ProductListing
component holds theProduct
component, which, in turn, renders the product information. TheTags
component holds multipleTag
components. State exists at theApp
level in order to hold selected tag information and at theProduct
level to toggle description visibility. - Create the app in the command line using
create-react-app
with the namereact-state-props
and run the app in development mode:npx create-react-app react-state-props cd comment-app yarn start
- In
src/App.js
, import the data from the JSON file and extract the objects from it:import React, { Component } from "react"; // styles import "./App.css"...