स्टेट कोठे राहते हे ठरविणे ही सर्वात महत्वाची आर्किटेक्चर कौशल्ये आहेत. मार्गदर्शक तत्व: प्रत्येक स्टेट च्या तुकड्याला सर्वात संकुचित स्कोप मध्ये ठेवा जो अजूनही सर्वांना संतुष्ट करते ज्यांना तिची गरज आहे — आणि प्रत्येक प्रकारचे स्टेट योग्य साधनाशी जुळवा.
निर्णय फ्रेमवर्क
1. Who needs this state?
- One component → local state (useState)
- A few related components → lift to common parent / small context
- Many distant components → global store or context
2. What KIND of state is it?
- Server/remote data → server-state library (React Query/SWR)
- UI/client state → useState / Zustand / Redux
- URL-derivable (filters, page) → the URL (searchParams)
- Form input → form library or local state
3. How OFTEN does it change?
- Rarely, widely shared (theme) → Context is fine
- Frequently, widely shared → store with selective subscriptions
