Create one component that is responsible for displaying the people list as a whole, and then a second component that is responsible for displaying the person in each row.We're shooting for generating something like:
![]()
You may either:
App.js (note that it's missing the code for the People Component):
import './App.css';
const data = [
{
id: "1276",
name: "Neil Rhodes",
email: "rhodes@hmc.edu",
phone: "(909) 555-1212"
},
{
id: "787",
name: "Barack Obama",
email: "ex-prez@whitehouse.gov",
phone: "(312) 555-1212"
}
];
function Person(props) {
return <div className="person"}>
<div className="name">{props.name}</div>
<div className="email">{props.email}</div>
<div className="phone">{props.phone}</div>
</div>
}
function App() {
return <div>
<People list={data}/>
</div>;
}
export default App;
App.css:
.person {
display: flex;
width: 400pt;
justify-content: space-between;
}
.name {
font-weight: bold;
}
.email {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}
At this point, you should have an app that is displaying each person using two components: one for the list, and one for each row.
Hint: In React, you can specify an onClick attribute for a component whose value is a JavaScript callback function. When the component, or some descendant of the component, is clicked, this callback function will be called with an event, e.
Hint: In JavaScript, if a is an array of strings ["red", "green", "blue"], then a.join(" ") yields "red green blue".
Hint: Add a useEffect hook.
Hint: DOM events contain a shiftKey boolean attribute.