Skip to content

Commit

Permalink
fix: add suspense to tag
Browse files Browse the repository at this point in the history
  • Loading branch information
SidonieBouthors committed Aug 17, 2024
1 parent ed4eaa1 commit 7e99c63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/share/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ArticleBlock from "@components/ArticleBlock";
import { posts, Post } from "@content";
import { Metadata } from "next";
import TagFilteredList from "@/components/TagFilteredList";
import { Tag } from "@components/Tag";
import TagFilteredList from "@components/TagFilteredList";
import Tag from "@components/Tag";

export const metadata: Metadata = {
title: "Share",
Expand Down
2 changes: 1 addition & 1 deletion components/ArticleBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { format } from "date-fns";
import Link from "next/link";
import { CalendarIcon } from "./icons/CalendarIcon";
import { Tag } from "@components/Tag";
import Tag from "@components/Tag";

interface ArticleBlockProps {
slug: string;
Expand Down
12 changes: 10 additions & 2 deletions components/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import Link from "next/link";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { Suspense } from "react";

interface TagProps {
tag: string;
Expand All @@ -12,7 +12,7 @@ interface TagProps {
* A tag component that can be used to filter content by tag.
* If no children are provided, the tag string will be displayed.
*/
export function Tag({ tag, children }: TagProps) {
function SuspenseTag({ tag, children }: TagProps) {
const searchParams = useSearchParams();
const pathname = usePathname();
const { replace } = useRouter();
Expand Down Expand Up @@ -50,3 +50,11 @@ export function Tag({ tag, children }: TagProps) {
</button>
);
}

export default function Tag({ tag, children }: TagProps) {
return (
<Suspense>
<SuspenseTag tag={tag}>{children}</SuspenseTag>
</Suspense>
);
}

0 comments on commit 7e99c63

Please sign in to comment.