fix: lazyloading issues on about page

This commit is contained in:
Melvin Ragusa
2026-01-23 11:35:18 +01:00
parent 1aead86921
commit 4955c41dc0
6 changed files with 29 additions and 13 deletions

View File

@@ -2,7 +2,6 @@
import { render, fireEvent, act } from '@testing-library/react';
import { FancyCursor } from './FancyCursor';
import { describe, it, expect, vi, beforeAll, afterAll, beforeEach } from 'vitest';
import React from 'react';
describe('FancyCursor', () => {
beforeAll(() => {

View File

@@ -14,7 +14,7 @@ describe('Navbar Performance', () => {
scrollYGetterSpy = vi.fn(() => 0);
Object.defineProperty(window, 'scrollY', {
configurable: true,
get: scrollYGetterSpy,
get: scrollYGetterSpy as any,
});
vi.useFakeTimers();
});

View File

@@ -0,0 +1,16 @@
import { useLayoutEffect } from 'react';
import { useLocation } from 'react-router-dom';
export function ScrollToTop() {
const { pathname } = useLocation();
useLayoutEffect(() => {
window.scrollTo({
top: 0,
left: 0,
behavior: 'instant'
});
}, [pathname]);
return null;
}

View File

@@ -1,3 +1,4 @@
export { Navbar } from './Navbar';
export { Footer } from './Footer';
export { FancyCursor } from './FancyCursor';
export { ScrollToTop } from './ScrollToTop';