Summarize the five principles for structuring state.
A. Group related state. If you always update two or more state variables at the same time, consider merging them into a single state variable.
B. Avoid contradictions in state. When the state is structured in a way that several pieces of state may contradict and “disagree” with each other, you leave room for mistakes. Try to avoid this.
C. Avoid redundant state. If you can calculate some information from the component’s props or its existing state variables during rendering, you should not put that information into that
component’s state.
D. Avoid duplication in state. When the same data is duplicated between multiple state variables, or within nested objects, it is difficult to keep them in sync. Reduce duplication when you can.
E. Avoid deeply nested state. Deeply hierarchical state is not very convenient to update. When possible, prefer to structure state in a flat way.