-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmain-final.jsx
47 lines (40 loc) · 974 Bytes
/
main-final.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// ESModules import syntax
// ReactDOM is the "default" export of this package
import ReactDOM from "react-dom/client";
const Header = () => {
return <h1>My Pet Pics</h1>;
};
const InstagramPost = ({src, caption}) => {
return (
<div className="insta-pic">
<img alt="cat pic" src={src} />
<p>{caption}</p>
</div>
);
};
const pictures = [
{ src: "img/cat.jpeg", caption: "meow!" },
{ src: "img/dog.jpeg", caption: "arf!" },
{ src: "img/duck.jpeg", caption: "quack!" },
];
// Create an <InstagramPost /> for each element
const InstagramPosts = pictures.map((picture, idx) => {
return (
<InstagramPost key={idx} src={picture.src} caption={picture.caption} />
);
});
// Render the array in a ul
const PicturesList = () => {
return <div>{InstagramPosts}</div>;
};
const App = () => {
return (
<>
<Header />
<PicturesList />
</>
);
};
ReactDOM.createRoot(document.querySelector("#root")).render(
<App />
);