import { AuthStoreType } from "@/types/store/auth.type";import { create } from "zustand";import { persist, PersistStorage } from "zustand/middleware";// Custom storage for zustandconst customStorage: PersistStorage = { getItem: (name) => { const item = localStorage.getItem(name); return item ? JSON.parse(item) : null; }, setItem: (name, value) => { localStorage.setItem(name, JSON.str..
라이브러리/zustand
소개Zustand는 React의 상태 관리를 간단하고 효율적으로 할 수 있게 도와주는 경량 상태 관리 라이브러리입니다.Redux보다 보일러플레이트 코드가 적고, 사용법이 직관적이며 Hooks 기반으로 동작합니다. 특징1. 간단한 사용법: React Hooks 스타일로 상태를 관리합니다.2. 가벼운 라이브러리: 약 1KB로 매우 가볍습니다.3. 보일러플레이트 최소화: 리듀서, 액션 정의 등이 필요 없습니다.4. 직관적: 상태 정의 및 사용이 단순하고 명확합니다.5. React에 최적화: React에서 사용하기 편리합니다. 설치npm install zustand 기본 사용법1. 상태 스토어 생성Zustand는 create 함수를 사용해 상태 스토어를 정의합니다.예시: store/CounterStore.ts..