Memoize context values

This commit is contained in:
jeffvli 2023-08-08 00:38:32 -07:00
parent 1111fd00a1
commit e542fcb8aa
4 changed files with 36 additions and 8 deletions

View file

@ -1,5 +1,5 @@
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
import { useRef } from 'react';
import { useMemo, useRef } from 'react';
import { useParams } from 'react-router';
import { PlaylistListSort, SortOrder } from '/@/renderer/api/types';
import { VirtualInfiniteGridRef } from '/@/renderer/components/virtual-grid';
@ -38,9 +38,16 @@ const PlaylistListRoute = () => {
? undefined
: itemCountCheck.data?.totalRecordCount;
const providerValue = useMemo(() => {
return {
id: playlistId,
pageKey,
};
}, [playlistId]);
return (
<AnimatedPage>
<ListContext.Provider value={{ id: playlistId, pageKey }}>
<ListContext.Provider value={providerValue}>
<PlaylistListHeader
gridRef={gridRef}
itemCount={itemCount}