Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
React cart state management: duplicate prevention, localStorage persistence, CartContext patterns. Use when building or fixing shopping carts, product lists,...
React cart state management: duplicate prevention, localStorage persistence, CartContext patterns. Use when building or fixing shopping carts, product lists,...
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
Patterns for React cart state: duplicate prevention, persistence, context design.
Track product IDs in CartContext (separate state or derived from cartItems) Check productIdsInCart.includes(item.id) before add Centralize logic in context, not in ProductCard or child components
Initialize cart state from localStorage.getItem('cart') on mount Persist on every add/remove: localStorage.setItem('cart', JSON.stringify(cartItems)) Sync productIdsInCart if used: localStorage.setItem('cart_ids', JSON.stringify(ids)) Prevents duplicates across sessions (refresh, new tab)
const addToCart = (item: CartItem) => { if (!productIdsInCart.includes(item.id)) { setCartItems(prev => [...prev, item]); setProductIdsInCart(prev => [...prev, item.id]); localStorage.setItem('cart', JSON.stringify([...cartItems, item])); } };
Don't add to cart in useEffect on ProductCard mount (causes duplicates) Don't duplicate logic in multiple components β use context Add backend validation as fallback for data integrity
For same-product quantity: use cartItems.map() to update item.quantity, don't create duplicate entries.
Agent frameworks, memory systems, reasoning layers, and model-native orchestration.
Largest current source with strong distribution and engagement signals.