Prompt
APIs return arrays; stores want lookup tables. Write entitiesReducer(state, action) over { byId: {}, allIds: [] }:
{ type: 'ADD', entity }— entity has anid; adds to both structures (ignore if id exists){ type: 'UPDATE', id, changes }— shallow-merges changes into the entity (no-op if missing){ type: 'REMOVE', id }— removes from both structures- Pure — new objects on every change,
allIdspreserves insertion order
Hints
Solution
Your Code
15 min