Loading react-frontend/my-react-app/src/components/BlogEntries.js +39 −28 Original line number Diff line number Diff line import React, { useState, useEffect } from "react"; import { Link } from "react-router-dom"; // Assuming you're using React Router import { Link, NavLink } from "react-router-dom"; // Assuming you're using React Router const BlogEnties = () => { const [entries, setEntries] = useState([]); Loading @@ -15,7 +15,8 @@ const BlogEnties = () => { throw new Error(`HTTP error! Status: ${response.status}`); } const data = await response.json(); setEntries(data); console.log('Logging of fetched data ', data); setEntries(data.entries); } catch (err) { setError(err.message); } finally { Loading @@ -31,8 +32,11 @@ const BlogEnties = () => { return ( <div> <h1>Blog Entries</h1> <table border="1" style={{ width: "100%", borderCollapse: "collapse" }}> <h2>Blog Entries</h2> <hr /> {entries && ( <table className="table"> <thead> <tr> <th>ID</th> Loading @@ -52,12 +56,19 @@ const BlogEnties = () => { <td>{new Date(entry.published).toLocaleString()}</td> <td>{new Date(entry.updated).toLocaleString()}</td> <td> <Link to={`/update-entry/${entry.id}`}>Update</Link> <NavLink className="btn btn-hoh-blue btn-sm" to={`/update-entry/${entry.slug}`} > Update entry </NavLink> {/* <Link to={`/update-entry/${entry.id}`}>Update</Link> */} </td> </tr> ))} </tbody> </table> )} </div> ); }; Loading Loading
react-frontend/my-react-app/src/components/BlogEntries.js +39 −28 Original line number Diff line number Diff line import React, { useState, useEffect } from "react"; import { Link } from "react-router-dom"; // Assuming you're using React Router import { Link, NavLink } from "react-router-dom"; // Assuming you're using React Router const BlogEnties = () => { const [entries, setEntries] = useState([]); Loading @@ -15,7 +15,8 @@ const BlogEnties = () => { throw new Error(`HTTP error! Status: ${response.status}`); } const data = await response.json(); setEntries(data); console.log('Logging of fetched data ', data); setEntries(data.entries); } catch (err) { setError(err.message); } finally { Loading @@ -31,8 +32,11 @@ const BlogEnties = () => { return ( <div> <h1>Blog Entries</h1> <table border="1" style={{ width: "100%", borderCollapse: "collapse" }}> <h2>Blog Entries</h2> <hr /> {entries && ( <table className="table"> <thead> <tr> <th>ID</th> Loading @@ -52,12 +56,19 @@ const BlogEnties = () => { <td>{new Date(entry.published).toLocaleString()}</td> <td>{new Date(entry.updated).toLocaleString()}</td> <td> <Link to={`/update-entry/${entry.id}`}>Update</Link> <NavLink className="btn btn-hoh-blue btn-sm" to={`/update-entry/${entry.slug}`} > Update entry </NavLink> {/* <Link to={`/update-entry/${entry.id}`}>Update</Link> */} </td> </tr> ))} </tbody> </table> )} </div> ); }; Loading