react · Medium · upload lifecycle
A React upload panel lets the user replace a file while the previous upload is still running. Progress and completion from the old upload currently overwrite the new file.
Task
Reduce choose, progress, complete, fail and remove events so only the current upload owns visible state.
Contract
Input is {events}. choose carries id and name; other events carry id. Return {fileName,progress,status,error,aborted}.
Acceptance criteria
- Choosing a file aborts the previous active ID.
- Ignore stale progress and settlements.
- Clamp current progress to 0..100.
- Remove aborts current work and clears visible state.
Constraints
- Do not mutate caller-owned input.
- Keep the supplied framework adapter and public contract unchanged.
- Add candidate tests for at least one boundary not covered by the public cases.
Editable files
src/repair.js— Task-specific state or service boundarytests/candidate.test.js— Candidate-authored regression