fix(dashboard): reduce re-renders for pages table
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
'use client';
|
||||
|
||||
import { memo } from 'react';
|
||||
import { LazyChart } from '@/components/report/chart/LazyChart';
|
||||
import { useNumber } from '@/hooks/useNumerFormatter';
|
||||
import { cn } from '@/utils/cn';
|
||||
import isEqual from 'lodash.isequal';
|
||||
import { ExternalLinkIcon } from 'lucide-react';
|
||||
|
||||
import type { IServicePage } from '@openpanel/db';
|
||||
|
||||
export function PagesTable({ data }: { data: IServicePage[] }) {
|
||||
export const PagesTable = memo(
|
||||
({ data }: { data: IServicePage[] }) => {
|
||||
const number = useNumber();
|
||||
const cell =
|
||||
'flex min-h-12 whitespace-nowrap px-4 align-middle shadow-[0_0_0_0.5px] shadow-border';
|
||||
@@ -111,4 +114,10 @@ export function PagesTable({ data }: { data: IServicePage[] }) {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
(prevProps, nextProps) => {
|
||||
return isEqual(prevProps.data, nextProps.data);
|
||||
}
|
||||
);
|
||||
|
||||
PagesTable.displayName = 'PagesTable';
|
||||
|
||||
@@ -618,7 +618,7 @@ export async function getTopPages({
|
||||
WHERE name = 'screen_view'
|
||||
AND project_id = ${escape(projectId)}
|
||||
AND created_at > now() - INTERVAL 30 DAY
|
||||
${search ? `AND path LIKE '%${search}%'` : ''}
|
||||
${search ? `AND path ILIKE '%${search}%'` : ''}
|
||||
GROUP BY path, project_id, origin
|
||||
ORDER BY count desc
|
||||
LIMIT ${take}
|
||||
|
||||
Reference in New Issue
Block a user