நிலை எங்கு வாழ்கிறது என்பதை தீர்மானிக்கது மிக முக்கியமான ஆர்கிட்டெக்சர் திறன்களில் ஒன்றாகும். வழிகாட்டும் கொள்கை: ஒவ்வொரு நிலையின் பகுதியையும் மிகக் குறுக்கமான நோக்கத்தில் வைக்கவும், இது இன்னும் அதை தேவைப்படுவோர் அனைவரையும் திருப்திப்படுத்துகிறது — மற்றும் ஒவ்வொரு வகை நிலையையும் சரியான கருவியுடன் பொருத்தவும்.
ஒரு முடிவு முறைக்கு
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
