Skip to content

Commit 9b6284e

Browse files
fix: add suspense to query filtered list
1 parent 07a9659 commit 9b6284e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

components/TagFilteredList.tsx

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"use client";
22

3-
import { Post } from "@content";
43
import { useSearchParams } from "next/navigation";
5-
import ArticleBlock from "@components/ArticleBlock";
4+
import { Suspense } from "react";
65

76
interface TaggedItem {
87
content: React.ReactNode;
@@ -14,11 +13,7 @@ interface TagFilteredListProps {
1413
children: TaggedItem[];
1514
}
1615

17-
/**
18-
* Displays a list of items, filtering them based on the tags in the URL query.
19-
* @param children The items to display, each with a `content`, `tags`, and `slug` property.
20-
*/
21-
export default function TagFilteredList({ children }: TagFilteredListProps) {
16+
function SuspenseTagFilteredList({ children }: TagFilteredListProps) {
2217
const selectedTags = useSearchParams().get("tags")?.split(",") || [];
2318

2419
let filteredItems = children;
@@ -40,3 +35,15 @@ export default function TagFilteredList({ children }: TagFilteredListProps) {
4035
</ul>
4136
);
4237
}
38+
39+
/**
40+
* Displays a list of items, filtering them based on the tags in the URL query.
41+
* @param children The items to display, each with a `content`, `tags`, and `slug` property.
42+
*/
43+
export default function TagFilteredList({ children }: TagFilteredListProps) {
44+
return (
45+
<Suspense fallback={<p>Loading...</p>}>
46+
<SuspenseTagFilteredList>{children}</SuspenseTagFilteredList>
47+
</Suspense>
48+
);
49+
}

0 commit comments

Comments
 (0)