Skip to content

Commit

Permalink
Add Bookmark Listing React Component
Browse files Browse the repository at this point in the history
  • Loading branch information
adilk0728 committed Feb 16, 2024
1 parent 3f5ceed commit 0813743
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
1 change: 0 additions & 1 deletion frontend-mark-alive/mark-alive/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
8 changes: 5 additions & 3 deletions frontend-mark-alive/mark-alive/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import BookmarkList from "./components/BookmarkList";
function App() {
return ( <>
<h1>First React Component</h1>
</>
return (
<div>
<BookmarkList />
</div>
);
}

Expand Down
19 changes: 19 additions & 0 deletions frontend-mark-alive/mark-alive/src/components/BookmarkList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useEffect, useState } from "react";
import List from "./List";

const BookmarkList = () => {
const [urlList, setUrlList] = useState([]);

useEffect(() => {
fetch("http://localhost:8080/bookmarks")
.then((resp) => resp.json())
.then((data) => setUrlList(data));
}, [urlList]);
return (
<div>
<List Headers={["ID", "URLs"]} data={urlList} />
</div>
);
};

export default BookmarkList;
25 changes: 25 additions & 0 deletions frontend-mark-alive/mark-alive/src/components/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export const List = ({ Headers, data }) => {
return (
<div>
<table>
<thead>
<tr>
{Headers.map((element, index) => (
<th key={index}>{element}</th>
))}
</tr>
</thead>
<tbody>
{data.map((element, index) => (
<tr key={element.id}>
<td>{element.id}</td>
<td>{element.url}</td>
</tr>
))}
</tbody>
</table>
</div>
);
};

export default List;

0 comments on commit 0813743

Please sign in to comment.