Lab 7: Displaying List Data
Objectives
- Format the list data as list items
- Format the list data as cards
Steps
Format the list data as list items
- Modify - src\projects\ProjectList.jsxto format the project information into a- HTMLunordered list.- <ul>
 <li>Project Name 1</li>
 <li>Project Name 2</li>
 </ul>- Be sure to set a key for each list item. - src\projects\ProjectList.jsx- ...
 function ProjectList({ projects }) {
 - return <pre>{JSON.stringify(projects, null, ' ')}</pre>;
 + return (
 + <ul className="row">
 + {projects.map((project) => (
 + <li key={project.id}>{project.name}</li>
 + ))}
 + </ul>
 + );
 }
 export default ProjectList;
- Verify the project names display in the browser (they may overlap at this point). 
Format the list data as cards
- Update - src\projects\ProjectList.jsxto format the project information into a rows of cards that show additional project information using the- HTMLtemplate below.- <div class="cols-sm">
 <div class="card">
 <img src="project image url" alt="project name" />
 <section class="section dark">
 <h5 class="strong">
 <strong>project name</strong>
 </h5>
 <p>project description</p>
 <p>Budget : project budget</p>
 </section>
 </div>
 </div>- Remember that you will need to replace attribute - classwith- classNameand change html attributes from- src="project image url"to- src={project.imageUrl}.- TIP: Visual Studio Code has an extension HTML to JSX to do the attribute conversion. - src\projects\ProjectList.jsx- ...
 function ProjectList({ projects }) {
 - return (
 - <ul className="row">
 - {projects.map((project) => (
 - <li key={project.id}>{project.name}</li>
 - ))}
 - </ul>
 - );
 }
 export default ProjectList;- ...
 function ProjectList({ projects }) {
 + return (
 + <div className="row">
 + {projects.map((project) => (
 + <div key={project.id} className="cols-sm">
 + <div className="card">
 + <img src={project.imageUrl} alt={project.name} />
 + <section className="section dark">
 + <h5 className="strong">
 + <strong>{project.name}</strong>
 + </h5>
 + <p>{project.description}</p>
 + <p>Budget : {project.budget.toLocaleString()}</p>
 + </section>
 + </div>
 + </div>
 + ))}
 + </div>
 + );
 }
 export default ProjectList;
- Download the code snippets, data, and images needed for the labs by following these steps. - Click this link to open the starter files repository on GitHub.
- Click the Green Code button then choose Download ZIP.
 
- Open File Explorer (Windows) or Finder (Mac) and go to your - downloadsdirectory.
- Unzip the file - react-starter-files-main.ziparchive you just downloaded.
- If it doesn't already exist, create the directory - projectpilot\public
- Copy the - assetsdirectory (which has images used in the application) and its contents into the- projectpilot\publicdirectory.danger- Do not copy the assets into the projectpilot\src\assetsdirectory. You want to place the images intoprojectpilot\public\assets
 
- Do not copy the assets into the 
- Verify the project data displays correctly in the browser. tip- If the images aren't loading refresh your browser. Vite's reloading is fast but not perfect.  
Note you can use
toLocaleStringto format the project budgetnumberin JavaScript.
<p>Budget : {project.budget.toLocaleString()}</p>
If you need to format something in React, ask yourself or
google.com: How would I do this in JavaScript?