Skip to content

Commit

Permalink
fix: fixing CV path + memoizing functions in Navigation.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
krckyboy committed Nov 18, 2024
1 parent f12e65f commit bc3582d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions frontend/src/app/blog/_navigation/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent, useMemo } from 'react';
import React, { FunctionComponent, useCallback, useMemo } from 'react';
import styles from './styles.module.scss';
import Link from 'next/link';
import qs from 'qs';
Expand All @@ -14,13 +14,13 @@ const Navigation: FunctionComponent<Props> = ({ currentPageCount, pageNumber, ca
const rangeEnd = currentPageCount;
const maxPagesToShow = 3;

const generateQueryString = (page: number) => {
const generateQueryString = useCallback((page: number) => {
const queryParams = {
category,
page
};
return qs.stringify(queryParams);
};
}, [category]);

const generatePageLinks = () => {
const links = [];
Expand Down Expand Up @@ -66,7 +66,7 @@ const Navigation: FunctionComponent<Props> = ({ currentPageCount, pageNumber, ca
return links;
};

const memoizedGeneratePageLinks = useMemo(() => generatePageLinks(), [rangeStart, pageNumber, rangeEnd, maxPagesToShow]);
const memoizedGeneratePageLinks = useMemo(generatePageLinks, [pageNumber, rangeEnd, generateQueryString]);

return (
<div className={styles.container}>
Expand Down

0 comments on commit bc3582d

Please sign in to comment.