fix: lazyloading issues on about page
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
16
src/components/layout/ScrollToTop.tsx
Normal file
16
src/components/layout/ScrollToTop.tsx
Normal 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;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export { Navbar } from './Navbar';
|
||||
export { Footer } from './Footer';
|
||||
export { FancyCursor } from './FancyCursor';
|
||||
export { ScrollToTop } from './ScrollToTop';
|
||||
|
||||
Reference in New Issue
Block a user