Let's design state for a messaging app.
State structure:
{
// Normalized entities
conversations: { byId: {}, allIds: [] },
messages: { byId: {} },
users: { byId: {} },
// UI state
ui: {
activeConversationId: null,
messageInput: "",
isComposing: false
},
// Server state metadata
status: {
conversations: { loading: false, error: null },
messages: { loading: false, error: null }
}
}
Keep entities (normalized), UI state (local), and loading states distinct.