Open
Conversation
Author
리액트 투두 앱 만들기 미션 레포React-Vite Todo App간단한 React + Vite 기반 Todo 리스트 애플리케이션입니다. 개발 기간📅 2025.07.08 – 2025.07.09 주요 기능
기술 스택
실행 이미지 |
kku1403
reviewed
Jul 11, 2025
| // src/utils/storage.js | ||
|
|
||
| export const getStorage = (key) => | ||
| JSON.parse(localStorage.getItem(key) || "null"); |
There was a problem hiding this comment.
null 값일 때의 처리 로직이 깔끔하고 좋네요!
처음에는 왜 null이 아니라 "null"이지? 했는데 JSON.parse() 때문이었군요 최곱니다 👍
다만 getStorage에 2번째 인자로 초기값을 넣어주면 useTodos에서 로컬 스토리지에 저장된 데이터를 불러올 때 null처리를 따로 안해줘도 될 것 같아요. 참고하시면 좋을 것 같습니다
| ]; | ||
| }); | ||
| useEffect(() => { | ||
| localStorage.setItem("todos", JSON.stringify(todos)); |
There was a problem hiding this comment.
storage.js에서 정의한 setStorage가 아니라 localStorage의 내장 함수를 사용하고 계신데 특별한 이유가 있나요?
|
수고하셨습니다! 코드 잘 봤습니다. |
jjuchan
reviewed
Jul 11, 2025
| @@ -0,0 +1,43 @@ | |||
| import { useRef, useState, useEffect } from "react"; | |||
| import { getStorage, setStorage } from "../utils/storage"; | |||
|
|
|||
There was a problem hiding this comment.
여기 setStorage import는 하셨는데 어디서 사용하신건가요??
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.