From b09ad68ab8489c27e7d14d92fcd2e35040fc79ac Mon Sep 17 00:00:00 2001 From: KANGYONGSU23 Date: Fri, 15 Dec 2023 17:34:53 +0900 Subject: [PATCH] =?UTF-8?q?feat=20::=20=EC=BD=94=EB=A9=98=ED=8A=B8=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit indexOf 대신 startWith매서드 사용 --- src/components/common/Header.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 2bd01b0..ffc8f7a 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -14,24 +14,26 @@ function Header() { const pathname = usePathname(); const { userProfile, setUserProfile } = useContext(UserProfileContext); const [cookies] = useCookies(); + console.log(pathname); + useEffect(() => { if ( - pathname.toString().indexOf("/apply") !== -1 || - pathname.toString().indexOf("/account") !== -1 + pathname.toString().startsWith("/apply", 13) || + pathname.toString().startsWith("/account") ) { document.querySelector("body")!.style.backgroundColor = "#fafafa"; } else { document.querySelector("body")!.style.backgroundColor = "#ffffff"; } }, [pathname]); - + useEffect(() => { - if(cookies.access_token){ + if (cookies.access_token) { useMyProfile(setUserProfile); } }, [cookies.access_token]); - if (pathname.toString().indexOf("/account") !== -1) { + if (pathname.toString().startsWith("/account")) { return null; }