Why is it important to avoid duplicating state?
Because duplicated state = a source of bugs. Always.
What happens when you duplicate:
- You change one value and forget the other
- The UI shows one thing while the logic thinks another
- It's unclear which of the copies is "the real one"
- Manual synchronization becomes necessary
- Bugs happen "seemingly at random"
Example:
You store a products list and a separate filteredProducts list.
Then you update products, but forget to update filteredProducts -
the screen shows stale data.
How to avoid it:
- Use derived state whenever something can be computed
- Keep a single source of truth
- Never store a "copy for convenience" without a good reason
Conclusion: Duplicated state is a trap for the mind and for bugs. The fewer places where data lives, the cleaner, simpler, and more reliable everything works.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.