Skip to content

Commit

Permalink
JobList: Fix a hang when sorting
Browse files Browse the repository at this point in the history
Somehow, the filter call was causing a render loop. Memoizing fixes that.

Signed-off-by: Zack Cerza <zack@redhat.com>
  • Loading branch information
zmc committed Jun 17, 2024
1 parent 07e51f2 commit c8cdceb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/JobList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import { ReactNode, useMemo } from "react";
import DescriptionIcon from "@mui/icons-material/Description";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
Expand Down Expand Up @@ -202,7 +202,9 @@ type JobListProps = {

export default function JobList({ query, sortMode }: JobListProps) {
const options = useDefaultTableOptions<Job>();
const data = (query.data?.jobs || []).filter(item => item.id);
const data = useMemo(() => {
return (query.data?.jobs || []).filter(item => !! item.id);
}, [query, sortMode]);
const table = useMaterialReactTable({
...options,
columns,
Expand Down

0 comments on commit c8cdceb

Please sign in to comment.