From e33e4bdc7f7d8dd3e750c64939b8f50a2dab6bb3 Mon Sep 17 00:00:00 2001 From: sryung Date: Thu, 11 Jan 2024 03:50:11 +0900 Subject: [PATCH] =?UTF-8?q?[=F0=9F=9B=A0=20:=20fix]=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=95=84=20=EC=88=98=EC=A0=95=EC=8B=9C=20=EB=A6=AC=EB=A0=8C?= =?UTF-8?q?=EB=8D=94=EB=A7=81=20=EC=A0=81=EC=9A=A9=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - useEffect의 dependency로 유저 데이터를 넣어 상태 변화와 동시에 리렌더링할 수 있도록 함 - 이전에 리렌더링 적용했었으나 프로필 확장 작업 중 누락된 것으로 추정 --- src/routes/profile.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/routes/profile.tsx b/src/routes/profile.tsx index 0372416..122d96f 100644 --- a/src/routes/profile.tsx +++ b/src/routes/profile.tsx @@ -1,17 +1,20 @@ import { useEffect, useState } from 'react'; import { useLocation } from 'react-router-dom'; +import { useRecoilValue } from 'recoil'; +import { collection, getDocs, query, where } from 'firebase/firestore'; +import { db } from '@/firebase.ts'; import WindowTop from '@compo/window-top.tsx'; import UserProfile from '@compo/profile/user-profile.tsx'; import UserTimeline from '@compo/profile/user-timeline.tsx'; -import * as W from '@style/window.ts'; -import { collection, getDocs, query, where } from 'firebase/firestore'; -import { db } from '@/firebase.ts'; +import currentUserAtom from '@atom/current-user.tsx'; import IUser from '@type/IUser.ts'; +import * as W from '@style/window.ts'; export default function Profile() { const location = useLocation(); const userFromLocation = location.search.slice(7); const [user, setUser] = useState(); + const currentUser = useRecoilValue(currentUserAtom); useEffect(() => { const fetchUser = async () => { const usersQuery = query( @@ -27,7 +30,7 @@ export default function Profile() { } }; fetchUser(); - }, [userFromLocation]); + }, [userFromLocation, currentUser]); return (