-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathImageGalleryApp.js
More file actions
32 lines (27 loc) · 834 Bytes
/
ImageGalleryApp.js
File metadata and controls
32 lines (27 loc) · 834 Bytes
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
import React from 'react';
import { createRoot } from 'react-dom/client';
const ImageGallery = ({ links }) => {
const remove = (event) => {
event.target.parentElement.remove();
}
return (
<div>
{links.map((link, index) => <div key={index} className="image">
<img src={link} alt="" />
<button className="remove" onClick={event => remove(event)}>X</button>
</div>
)}
</div>
);
}
document.body.innerHTML = "<div id='root'> </div>";
const rootElement = document.getElementById("root");
const links = ["https://bit.ly/3lmYVna", "https://bit.ly/3flyaMj"];
const root = createRoot(rootElement);
root.render(<ImageGallery links={links} />);
setTimeout(() => {
document.querySelectorAll('.remove')[0]?.click();
setTimeout(() => {
console.log(rootElement?.innerHTML);
});
});