From 3761d8989ed3f24d5551aca532db517cbc5254d1 Mon Sep 17 00:00:00 2001 From: LSJ Date: Sat, 25 May 2024 14:55:13 +0900 Subject: [PATCH] add try-catch about parsing storage --- pages/vote.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pages/vote.tsx b/pages/vote.tsx index 5029fcb66..3d9529f78 100644 --- a/pages/vote.tsx +++ b/pages/vote.tsx @@ -1,7 +1,7 @@ import { Flex, ListItem, UnorderedList } from "@chakra-ui/react"; import dayjs from "dayjs"; -import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { useSession } from "next-auth/react"; +import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { useEffect, useState } from "react"; import { useRecoilValue } from "recoil"; import styled from "styled-components"; @@ -81,7 +81,12 @@ export default function StudyVoteMap() { if (!preferenceStorage && isLoading) return; if (myVote?.subPlace.length) return; - const savedPrefer = JSON.parse(preferenceStorage); + let savedPrefer; + try { + savedPrefer = JSON.parse(preferenceStorage); + } catch (error) { + savedPrefer = null; + } if (!savedPrefer && !studyPreference) { if (!isAlert) {