diff --git a/pages/index.tsx b/pages/index.tsx index 5ac310c3ff..5f8771ed6b 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -2,6 +2,7 @@ import Head from "next/head"; import styled from "styled-components"; import Link from "next/link"; import { useEffect, useState } from "react"; +import { safeGetItem } from "@src/utils/safeKey"; const Container = styled.div` height: 600px; @@ -31,10 +32,11 @@ function Home() { useEffect(() => { if (typeof window !== "undefined") { - const accessToken = localStorage.getItem("accessToken"); + const accessToken = safeGetItem("accessToken"); if (accessToken !== null) setToken(accessToken); } }, []); + return ( <>
diff --git a/src/components/sign/ErrorMessages.js b/src/components/sign/ErrorMessages.ts similarity index 100% rename from src/components/sign/ErrorMessages.js rename to src/components/sign/ErrorMessages.ts diff --git a/src/components/sign/SigninForm.tsx b/src/components/sign/SigninForm.tsx index 7c134e68cc..689128adb6 100644 --- a/src/components/sign/SigninForm.tsx +++ b/src/components/sign/SigninForm.tsx @@ -8,6 +8,8 @@ import { postSignIn } from "@src/api"; import { useRouter } from "next/router"; import Input from "@src/components/sign/Input"; import ERROR from "@src/components/sign/ErrorMessages"; +import { saveToLocalStorage } from "@src/utils/safeKey"; +import { emailTextInputProps } from "@src/utils/formProps"; type FormType = { email: string; @@ -32,7 +34,7 @@ function SigninForm() { console.log(accessToken); if (accessToken) { - localStorage.setItem("accessToken", accessToken); + saveToLocalStorage("accessToken", accessToken); } else { throw new Error("Access token이 없습니다."); } @@ -56,12 +58,8 @@ function SigninForm() {