React · Middle · Question 60 of 75
How do you avoid many boolean flags like isSending, isSent, isError at once?
- ✓Correct answer: Use one
statusstate with explicit values:'typing' | 'sending' | 'sent' | 'error' - 2Store each flag in a ref
- 3Use
useMemofor each flag
Explanation
Separate booleans allow impossible combinations (sending and sent at once). A single status variable - or a reducer - makes states explicit.