Skip to content

Commit 5dbdd08

Browse files
committed
conditional に rendering される component を nossr に
1 parent 1455f50 commit 5dbdd08

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

web/app/friends/page.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
"use client";
2-
32
import { useState } from "react";
4-
import Matchings from "~/components/match/matching";
5-
import Requests from "~/components/match/requests";
3+
4+
// https://nextjs.org/docs/messages/react-hydration-error#solution-2-disabling-ssr-on-specific-components
5+
import dynamic from "next/dynamic";
6+
const NoSSRMatchings = dynamic(() => import("~/components/match/matching"), {
7+
ssr: false,
8+
});
9+
const NoSSRRequests = dynamic(() => import("~/components/match/requests"), {
10+
ssr: false,
11+
});
612

713
export default function Friends() {
814
const [activeTab, setActiveTab] = useState("matching");
@@ -39,7 +45,7 @@ export default function Friends() {
3945

4046
{/* コンテンツ部分 */}
4147
<div className="mt-4 text-center text-gray-700 text-lg">
42-
{activeTab === "matching" ? <Matchings /> : <Requests />}
48+
{activeTab === "matching" ? <NoSSRMatchings /> : <NoSSRRequests />}
4349
</div>
4450
</div>
4551
);

web/components/match/matching.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ export default function Matchings() {
1414

1515
return (
1616
<div className="p-4">
17-
<p className="mr-10 ml-10 text-lg">
18-
{data && data.length === 0 && (
19-
<>
20-
誰ともマッチングしていません。
21-
<br />
22-
リクエストを送りましょう!
23-
</>
24-
)}
25-
</p>
17+
{data && data.length === 0 && (
18+
<p className="mr-10 ml-10 text-lg">
19+
誰ともマッチングしていません。 リクエストを送りましょう!
20+
</p>
21+
)}
2622
{current === "loading" ? (
2723
<FullScreenCircularProgress />
2824
) : error ? (

0 commit comments

Comments
 (0)