update component ShowLog

This commit is contained in:
joseph le 2023-09-13 08:14:48 +07:00
parent 68123de87d
commit 431745d22e
1 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import axios from "axios";
import React, { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { Navigate, useParams } from "react-router-dom";
import { getLog } from "../../api/apiLog";
import "./ShowLog.css";
const ShowLog = () => {
@ -12,14 +12,27 @@ const ShowLog = () => {
let tempContent = "";
const res = await axios.get(getLog + "/" + name);
setLog(res.data);
console.log(res.data)
} catch (error) {
console.log(error);
}
};
const scrollToElement = () => {
const hash = window.location.hash;
if (hash) {
const targetElement = document.getElementById(hash.slice(1)); // Replace "3" with the desired id
if (targetElement) {
targetElement.scrollIntoView({ behavior: "smooth" });
}
}
};
useEffect(() => {
getContentLog();
setTimeout(() => {
scrollToElement()
}, 1000);
}, []);
console.log(window.location.hash);
return (
<div className="main">
<div className="detectedDiv">