toolను రకమైన state కు పోల్చండి, డిఫాల్ట్ గా global store కు చేరుకోవడం కంటే. చాలా "global state" సమస్యలు నిజానికి ఈ పనికి తప్పు tool.
నిర్ణయ గైడ్
Local UI state (toggle, input) → useState / useReducer
Shared, low-frequency (theme, user) → Context
Server/API data → React Query / SWR (NOT a global store)
Complex global client state → Zustand / Jotai / Redux Toolkit
URL-shareable state (filters, page) → the URL (search params)
అత్యంత ముఖ్యమైన insight: server state ≠ client state
APIలో నుండి డేటా అనేది రిమోట్ డేటా యొక్క cache, మీరు స్వంతమైన state కాదు. దీన్ని Reduxలో ఉంచడం అంటే మీరు loading, caching, refetching, మరియు invalidation ను మానవీయంగా నిర్వహించాలి — బాధాకరమైనది మరియు bug-prone. Server-state library అన్నీ చేస్తుంది:
