diff --git a/app/[slug]/page.tsx b/app/[slug]/page.tsx index 8257b36..4c1c235 100644 --- a/app/[slug]/page.tsx +++ b/app/[slug]/page.tsx @@ -84,7 +84,6 @@ const PageStock = async ({ params }: Props) => { ) : ( Not data )} - ); diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index ae21423..349312d 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import Link from 'next/link'; import { Logo } from '@/components/Logo'; import { Profile } from '@/components/Profile'; @@ -10,9 +9,9 @@ export const Header = () => {
- + - +
diff --git a/components/StocksList/Pagination/LoadMore/LoadMore.tsx b/components/StocksList/Pagination/LoadMore/LoadMore.tsx new file mode 100644 index 0000000..e0cefda --- /dev/null +++ b/components/StocksList/Pagination/LoadMore/LoadMore.tsx @@ -0,0 +1,42 @@ +'use client'; + +import { useEffect, useRef } from 'react'; +import styles from '../pagination.module.scss'; +import Link from 'next/link'; + +interface LoadMoreProps { + currentStart: number; + currentEnd: number; + itemsPerPage: number; +} + +export const LoadMore = ({ + currentStart, + currentEnd, + itemsPerPage, +}: LoadMoreProps) => { + const scrollPosition = useRef(0); + + useEffect(() => { + if (scrollPosition.current > 0) { + window.scrollTo({ + top: scrollPosition.current, + }); + scrollPosition.current = 0; + } + }); + + const handleLoadMoreClick = () => { + scrollPosition.current = window.scrollY; + }; + + return ( + + Show more + + ); +}; diff --git a/components/StocksList/Pagination/LoadMore/index.ts b/components/StocksList/Pagination/LoadMore/index.ts new file mode 100644 index 0000000..2d94695 --- /dev/null +++ b/components/StocksList/Pagination/LoadMore/index.ts @@ -0,0 +1 @@ +export { LoadMore as default } from './LoadMore'; diff --git a/components/StocksList/Pagination/Pagination.tsx b/components/StocksList/Pagination/Pagination.tsx index 5b3283c..985ecd0 100644 --- a/components/StocksList/Pagination/Pagination.tsx +++ b/components/StocksList/Pagination/Pagination.tsx @@ -1,7 +1,8 @@ import Link from 'next/link'; import classNames from 'classnames'; import { createPageArray } from '@/utils'; - +import dynamic from 'next/dynamic'; +const LoadMore = dynamic(() => import('./LoadMore'), { ssr: false }); import styles from './pagination.module.scss'; export const Pagination = ({ @@ -35,12 +36,11 @@ export const Pagination = ({ return (
- - Show more - +