본문으로 건너뛰기
TakoAPI
스킬로 돌아가기

cart-management

konscious0beast 제작

Web & Frontend Development
325clawskills.sh가 보고한 다운로드 수
0조회수
좋아요 0개로그인하면 이 스킬에 좋아요를 누를 수 있습니다
—아직 평가 없음
내 평가

요약

React cart state management: duplicate prevention, localStorage persistence, CartContext patterns.

설명

이 스킬이 하는 일

Patterns for managing shopping cart state in React apps. Covers duplicate prevention, localStorage persistence, and CartContext design. Centralizes cart logic to avoid scattered state across components.

Centralizing cart logic in a context prevents the duplicate-state bugs that arise when multiple components each manage their own cart slice.

사용 시점

  • Preventing duplicate products when user clicks Add to Cart twice
  • Persisting cart contents after page refresh
  • Syncing cart state across multiple tabs
  • Updating item quantities without creating duplicate entries
  • Centralizing cart logic away from individual product components

예시 워크플로

입력

User asks: How do I add a product to the cart without allowing duplicates, and make it persist on refresh?

에이전트
  1. 1

    Create a CartContext with cartItems and productIdsInCart state

  2. 2

    Initialize cartItems from localStorage on mount

  3. 3

    Implement addToCart that checks productIdsInCart.includes(item.id) before adding

  4. 4

    On each add, update both state arrays and write to localStorage

  5. 5

    Provide the context via CartProvider wrapping the app

출력

A CartContext where duplicate adds are silently ignored, cart survives refresh, and all product components consume a single source of truth.

설치

clawhub install konscious0beast/cart-management

CLI 명령을 실행하거나, 프롬프트를 Claude Code, Cursor, Codex 등 사용하는 코딩 에이전트에 붙여넣으세요.

링크