From 214c91e3bf5aaf5f08d932c5e88b07aaae2ce357 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sun, 5 Oct 2025 17:05:05 +0900 Subject: [PATCH] #140 --- frontend/src/App.tsx | 11 +++++++++-- frontend/src/pages/posts/PostDetailPage.tsx | 11 ++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b4c9d86..2248239 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,7 +1,7 @@ import axios from 'axios' import toCamel from 'camelcase-keys' import { useEffect, useState } from 'react' -import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom' +import { BrowserRouter, Navigate, Route, Routes, useLocation } from 'react-router-dom' import RouteBlockerOverlay from '@/components/RouteBlockerOverlay' import TopNav from '@/components/TopNav' @@ -26,6 +26,13 @@ import type { FC } from 'react' import type { User } from '@/types' +const PostDetailRoute = ({ user }: { user: User | null }) => { + const location = useLocation () + const key = location.pathname + return +} + + export default (() => { const [user, setUser] = useState (null) const [status, setStatus] = useState (200) @@ -81,7 +88,7 @@ export default (() => { }/> }/> }/> - }/> + }/> }/> }/> }/> diff --git a/frontend/src/pages/posts/PostDetailPage.tsx b/frontend/src/pages/posts/PostDetailPage.tsx index de4a298..c7315b6 100644 --- a/frontend/src/pages/posts/PostDetailPage.tsx +++ b/frontend/src/pages/posts/PostDetailPage.tsx @@ -28,9 +28,10 @@ export default (({ user }: Props) => { const { id } = useParams () const { data: post, isError: errorFlg, error } = useQuery ({ - enabled: Boolean (id), - queryKey: ['posts', String (id)], - queryFn: () => fetchPost (String (id)) }) + enabled: Boolean (id), + queryKey: ['posts', String (id)], + queryFn: () => fetchPost (String (id)), + placeholderData: undefined }) const qc = useQueryClient () @@ -68,6 +69,10 @@ export default (({ user }: Props) => { setStatus (code) }, [errorFlg, error]) + useEffect (() => { + setStatus (200) + }, [id]) + switch (status) { case 404: