Skip to content

Commit

Permalink
perf: fix re-render loop
Browse files Browse the repository at this point in the history
  • Loading branch information
soof-golan committed Oct 22, 2024
1 parent a555af2 commit 2b6bf96
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions website/components/MarkdownCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ type MarkdownProps = {
desktopImageBlob?: string;
};

// NOTE: The query must be defined outside the component
// Otherwise, it will cause a re-render loop
const query = {
isMobile: {
maxWidth: 700,
},
};

export default function MarkdownCard({
content,
title,
desktopImageBlob,
mobileImageBlob,
}: MarkdownProps) {
const [params, containerRef] = useContainerQuery(
{
isMobile: {
maxWidth: 700,
},
},
{}
);
const [params, containerRef] = useContainerQuery(query, {});
const isMobile = params.isMobile;
const imageUrl = isMobile ? mobileImageBlob : desktopImageBlob;

Expand Down

0 comments on commit 2b6bf96

Please sign in to comment.