Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes to react render #241

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions frontend/components/evaluations/evaluations-groups-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ClientTimestampFormatter from "../client-timestamp-formatter";
import { ColumnDef } from "@tanstack/react-table";
import { DataTable } from "../ui/datatable";
import { swrFetcher } from "@/lib/utils";
import { useEffect } from "react";
import { useProjectContext } from "@/contexts/project-context";
import useSWR from "swr";

Expand All @@ -17,9 +18,11 @@ export default function EvaluationsGroupsBar() {
swrFetcher,
);

if (groups && groups.length > 0 && !searchParams.get('groupId')) {
router.push(`/project/${projectId}/evaluations?groupId=${groups[0].groupId}`);
}
useEffect(() => {
if (groups && groups.length > 0 && !searchParams.get('groupId')) {
router.replace(`/project/${projectId}/evaluations?groupId=${groups[0].groupId}`);
}
}, [groups, searchParams, router, projectId]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including 'searchParams' in the dependency array can cause unnecessary re-renders. Consider extracting the specific parameter needed, like 'searchParams.get("groupId")', and include that instead.

Suggested change
}, [groups, searchParams, router, projectId]);
}, [groups, searchParams.get("groupId"), router, projectId]);


const columns: ColumnDef<{ groupId: string, lastEvaluationCreatedAt: string }>[] = [
{
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/ui/mono-with-copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default function MonoWithCopy({
<div className="flex items-center group space-x-2">
<Mono className={className}>{children}</Mono>
<CopyToClipboard
text={String(children)}
// this is intentional, so that this fails if the children is not a string
text={children as string}
className="hidden group-hover:block max-h-4"
>
<Copy size={copySize ?? 16} />
Expand Down