Skip to content

Commit dd1df39

Browse files
committed
update keeper project using map and arrow functions
1 parent 30a0d21 commit dd1df39

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

keeper-app/src/components/App.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ import React from "react";
22
import Header from "./Header";
33
import Footer from "./Footer";
44
import Note from "./Note";
5+
import examples from "./examples";
56

67
function App() {
78
return (
89
<div>
910
<Header />
10-
<Note />
11+
{examples.map((example) => (
12+
<Note
13+
key={example.key}
14+
title={example.title}
15+
content={example.content}
16+
/>
17+
))}
1118
<Footer />
1219
</div>
1320
);

keeper-app/src/components/Note.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from "react";
22

3-
function Note() {
3+
function Note(props) {
44
return (
55
<div className="note">
6-
<h1>Title</h1>
7-
<p>Content</p>
6+
<h1>{props.title}</h1>
7+
<p>{props.content}</p>
88
</div>
99
);
1010
}

keeper-app/src/components/examples.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const examples = [
2+
{
3+
key: 1,
4+
title: "Delegation",
5+
content:
6+
"Q. How many programmers does it take to change a light bulb? A. None – It’s a hardware problem"
7+
},
8+
{
9+
key: 2,
10+
title: "Loops",
11+
content:
12+
"How to keep a programmer in the shower forever. Show him the shampoo bottle instructions: Lather. Rinse. Repeat."
13+
},
14+
{
15+
key: 3,
16+
title: "Arrays",
17+
content:
18+
"Q. Why did the programmer quit his job? A. Because he didn't get arrays."
19+
},
20+
{
21+
key: 4,
22+
title: "Hardware vs. Software",
23+
content:
24+
"What's the difference between hardware and software? You can hit your hardware with a hammer, but you can only curse at your software."
25+
}
26+
];
27+
28+
export default examples;

keeper-app/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
//HINT: You will need to study the classes in teh styles.css file to appy styling.
1313

14+
//7. Add example notes
15+
1416
import React from "react";
1517
import ReactDom from "react-dom";
1618
import App from "./components/App";

0 commit comments

Comments
 (0)