Skip to content

Commit

Permalink
Handle zero hits in MaterialGrid
Browse files Browse the repository at this point in the history
Introduced a guard check to ensure the `MaterialGrid` component is not rendered if there are no materials + logging the information to the console for debugging purposes.
  • Loading branch information
kasperbirch1 committed Jul 30, 2024
1 parent 51a7b30 commit 909a32d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/apps/material-grid/MaterialGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ const MaterialGrid: React.FC<MaterialGridProps> = ({
setShowAllMaterials(!showAllMaterials);
}

if (!materials.length) {
// eslint-disable-next-line no-console
console.warn(`No materials to show for MaterialGrid: ${title}`);
return null;
}

const titleClasses = clsx("material-grid__title", {
"material-grid__title--no-description": !description
});
Expand Down

0 comments on commit 909a32d

Please sign in to comment.