Lab 10: Creating a Form to Edit Your Data
Objectives
- Create a form component
- Render the form component
Steps
Create a form component
- Add the following CSS style to to set the width of the form. - src\index.cssform {min-width: 300px;}
- Create the file - src\projects\ProjectForm.js.
- Implement a - ProjectFormfunction component that meets the following specifications:- Paste the HTML below into the - ProjectFormand use your editor and the link below to identify the changes needed to the- HTMLto make it- JSX.- We will pass the - projectobject as a- propin a later lab so you just need to render the- HTMLfrom the previous step as- JSX.<form class="input-group vertical"><label for="name">Project Name</label><input type="text" name="name" placeholder="enter name" /><label for="description">Project Description</label><textarea name="description" placeholder="enter description"></textarea><label for="budget">Project Budget</label><input type="number" name="budget" placeholder="enter budget" /><label for="isActive">Active?</label><input type="checkbox" name="isActive" /><div class="input-group"><button class="primary bordered medium">Save</button><span></span><button type="button" class="bordered medium">cancel</button></div></form>- Solution- src\projects\ProjectForm.jsimport React from "react";function ProjectForm() {return (<form className="input-group vertical"><label htmlFor="name">Project Name</label><input type="text" name="name" placeholder="enter name" /><label htmlFor="description">Project Description</label><textarea name="description" placeholder="enter description" /><label htmlFor="budget">Project Budget</label><input type="number" name="budget" placeholder="enter budget" /><label htmlFor="isActive">Active?</label><input type="checkbox" name="isActive" /><div className="input-group"><button className="primary bordered medium">Save</button><span /><button type="button" className="bordered medium">cancel</button></div></form>);}export default ProjectForm;
 
Render the form component
- Open the file - src\projects\ProjectList.js.
- Render the - ProjectFormcomponent below the- ProjectCard.- src\projects\ProjectList.js...+ import ProjectForm from './ProjectForm';...function ProjectList ({ projects }) {const items = projects.map(project => (<div key={project.id} className="cols-sm"><ProjectCard project={project}></ProjectCard>+ <ProjectForm /></div>));return <div className="row">{items}</div>;}...
- Verify a form renders under each card in the application. Note, you may need to reload the application a few times to see the changes on this step.  
✔ You have completed Lab 10