Skip to content

Commit 7ad0df3

Browse files
authored
[Bugfix]: 없는 아이디 검색 navigate 후 새로 아이디 검색하면 맛 가는 문제 (#88)
* fix: errorboundary에 key값 추가 * fix: useSearchParams suspense내부에서 사용하게수정
1 parent 662b55f commit 7ad0df3

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

src/app/summoner-page/page.tsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,35 @@
22

33
import { Suspense } from "react";
44

5+
import { useSearchParams } from "next/navigation";
56
import { ErrorBoundary } from "react-error-boundary";
67

78
import { Spinner } from "@/components/ui";
89

910
import { ErrorPage, SummonerContent } from "./_components";
1011

11-
export default function SummonerPage() {
12+
const ErrorBoundaryWithKey = () => {
13+
const searchParams = useSearchParams();
14+
const id = searchParams.get("id");
15+
const tag = searchParams.get("tag");
16+
1217
return (
13-
<ErrorBoundary FallbackComponent={ErrorPage}>
14-
<Suspense
15-
fallback={
16-
<div className="flex h-96 w-full items-center justify-center">
17-
<Spinner />
18-
</div>
19-
}
20-
>
21-
<SummonerContent />
22-
</Suspense>
18+
<ErrorBoundary FallbackComponent={ErrorPage} key={`${id}-${tag}`}>
19+
<SummonerContent />
2320
</ErrorBoundary>
2421
);
22+
};
23+
24+
export default function SummonerPage() {
25+
return (
26+
<Suspense
27+
fallback={
28+
<div className="flex h-96 w-full items-center justify-center">
29+
<Spinner />
30+
</div>
31+
}
32+
>
33+
<ErrorBoundaryWithKey />
34+
</Suspense>
35+
);
2536
}

0 commit comments

Comments
 (0)