본문 바로가기

코딩쌀롱

검색하기
코딩쌀롱
프로필사진 이브✱

  • 모든 글 (126)
    • 개발공부 (70)
    • 책 (10)
    • 회고 (43)
      • 하루 기록 (25)
      • 회고 (18)
    • 아무것 (3)
    • 여행 (0)
Guestbook
Recent Posts
Recent Comments
Today
Total
«   2025/05   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Tags
  • 비동기
  • leetcode
  • bind
  • 코어자바스크립트
  • array
  • React
  • 회고
  • 프로그래머스
  • node.js
  • 아티클
  • 생성자
  • input
  • 링크드 리스트
  • Prototype
  • 알고리즘
  • 코드스쿼드
  • javascript
  • TS
  • Promise
  • closure
more
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록useState (1)

코딩쌀롱

[React] Lazy initial state

useState의 지연 초기화를 통해 리액트 함수 컴포넌트를 최적화시킬 수 있다. // 예제 1 const Counter = () => { const [count, setCount] = useState( Number.parseInt(window.localStorage.getItem(cacheKey)), ) useEffect(() => { window.localStorage.setItem(cacheKey, count) }, [cacheKey, count]) return ( Count: {count} setCount((prevCount) => prevCount - 1)}>- setCount((prevCount) => prevCount + 1)}>+ ) } // 예제 2 const Counter = () =>..

개발공부 2021. 4. 30. 03:15
Prev 1 Next

Blog is powered by kakao / Designed by Tistory

티스토리툴바