-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bookmark Listing React Component
- Loading branch information
Showing
4 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
frontend-mark-alive/mark-alive/src/components/BookmarkList.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |