Practice ยท 2 of 3
Discriminated Reducer
Write reduceRequest(state, action) for a request state machine. State is { kind: "idle" } | { kind: "loading" } | { kind: "success", data } | { kind: "error", message }. Actions: { type: "start" } โ loading; { type: "resolve", data } โ success; { type: "reject", message } โ error; { type: "reset" } โ idle. RETURN the new state; never mutate.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Unions & Narrowing โ Practice