Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/pages/myPage/MyPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { fetchIdols } from '@/apis/myPageApi.js';
import PrimaryButton from '@/components/PrimaryButton';
import xButton from '@/assets/icons/xButton.svg';

const storageKey = 'favoriteIdols';
const STORAGEKEY = 'favoriteIdols';

const MyPage = () => {
const [idols, setIdols] = useState([]);
Expand Down Expand Up @@ -39,7 +39,7 @@ const MyPage = () => {
}, []);

useEffect(() => {
const storedFavorites = localStorage.getItem(storageKey);
const storedFavorites = localStorage.getItem(STORAGEKEY);
if (storedFavorites) {
setFavoriteIdols(storedFavorites.split(',').map(Number));
}
Expand All @@ -58,7 +58,7 @@ const MyPage = () => {
if (selectedIdols.length === 0) return;
setFavoriteIdols((prev) => {
const updatedFavorites = [...new Set([...prev, ...selectedIdols])];
localStorage.setItem(storageKey, updatedFavorites.join(','));
localStorage.setItem(STORAGEKEY, updatedFavorites.join(','));
return updatedFavorites;
});
setSelectedIdols([]);
Expand All @@ -67,7 +67,7 @@ const MyPage = () => {
const handleRemoveFavorite = (idolId) => {
setFavoriteIdols((prev) => {
const updatedFavorites = prev.filter((id) => id !== idolId);
localStorage.setItem(storageKey, updatedFavorites.join(','));
localStorage.setItem(STORAGEKEY, updatedFavorites.join(','));
return updatedFavorites;
});
};
Expand Down