Skip to content

Commit

Permalink
add try-catch about parsing storage
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungJL committed May 25, 2024
1 parent 9830897 commit 3761d89
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pages/vote.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3761d89

Please sign in to comment.