diff --git a/src/pages/LocationDetail/index.tsx b/src/pages/LocationDetail/index.tsx index 9c15187..c67529f 100644 --- a/src/pages/LocationDetail/index.tsx +++ b/src/pages/LocationDetail/index.tsx @@ -31,6 +31,7 @@ function LocationDetail() { const [locationImages, setLocationImages] = useState(emptyLocationResponse()) const [currentUserReview, setCurrentUserReview] = useState() const [lightboxOpen, setLightboxOpen] = useState(false) + const[updatePage, setUpdatePage] = useState(true) const [pageState, setPageState] = useState({ critic_filter_name: 'highest rated', critic_filter_type: 0, @@ -74,13 +75,14 @@ function LocationDetail() { const res = await getImagesByLocationService({ page: 1, page_size: 15, location_id: Number(id) }) res.data.images.push({ src: thumbnail }) setLocationImages(res.data) + setUpdatePage(false) } catch (error) { console.log(error) } setIsLoading(false) } - async function getCurrentUserLocationReview() { + async function getCurrentUserLocationReview(): Promise { try { const res = await getCurrentUserLocationReviewService(Number(id)) setCurrentUserReview(res.data) @@ -165,6 +167,7 @@ function LocationDetail() { created_at: data.created_at, updated_at: data.updated_at }) + setUpdatePage(true) } catch (error) { let err = error as AxiosError; console.log(err) @@ -184,8 +187,13 @@ function LocationDetail() { useEffect(() => { getCurrentUserLocationReview() - getLocationDetail() }, []) + + useEffect(() => { + if(updatePage) { + getLocationDetail() + } + }, [updatePage]) return ( <>