Skip to content

Commit

Permalink
refactor: 불필요한 기본값 및 localStorage 유틸 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
cruelladevil committed May 15, 2023
1 parent f41ec9e commit 98adcd7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/atoms/cart.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AtomEffect, atom, selector } from 'recoil';
import { Cart } from '../types/cart';
import { getLocalData } from '../utils/localStorage';

const localStorageEffect: <T>(key: string) => AtomEffect<T> =
(key: string) =>
({ setSelf, onSet }) => {
const savedValue = localStorage.getItem(key);
if (savedValue != null) {

if (savedValue !== null) {
setSelf(JSON.parse(savedValue));
}

Expand All @@ -17,7 +17,7 @@ const localStorageEffect: <T>(key: string) => AtomEffect<T> =

export const cartState = atom<Cart[]>({
key: 'CartListState',
default: getLocalData('CART'),
default: [],
effects: [localStorageEffect<Cart[]>('CART')],
});

Expand Down
9 changes: 0 additions & 9 deletions src/utils/localStorage.ts

This file was deleted.

0 comments on commit 98adcd7

Please sign in to comment.