Skip to content

Commit

Permalink
fix: build error
Browse files Browse the repository at this point in the history
  • Loading branch information
GabsEdits committed Jun 11, 2024
1 parent ba620ee commit 5867ee5
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,28 +192,32 @@ export default function Home() {
};

useEffect(() => {
const hoverElement = document.querySelector("h1");
const originalColor = "var(--color-text)";
useEffect(() => {
const hoverElement = document.querySelector("h1");
const originalColor = "var(--color-text)";

hoverElement.addEventListener("mouseenter", function () {
const randomColor = getRandomColor();
hoverElement.style.color = randomColor;
});

hoverElement.addEventListener("mouseleave", function () {
hoverElement.style.color = originalColor;
});

return () => {
hoverElement.removeEventListener("mouseenter", function () {
if (hoverElement) {
hoverElement.addEventListener("mouseenter", function () {
const randomColor = getRandomColor();
hoverElement.style.color = randomColor;
});

hoverElement.removeEventListener("mouseleave", function () {
hoverElement.addEventListener("mouseleave", function () {
hoverElement.style.color = originalColor;
});
};

return () => {
hoverElement.removeEventListener("mouseenter", function () {
const randomColor = getRandomColor();
hoverElement.style.color = randomColor;
});

hoverElement.removeEventListener("mouseleave", function () {
hoverElement.style.color = originalColor;
});
};
}
}, []);
}, []);

function getRandomColor() {
Expand Down

0 comments on commit 5867ee5

Please sign in to comment.