The panel displays the current request for an employee profile. The user can quickly switch employeeId and mark the request as seen from the keyboard. In this scenario, the screen sometimes shows stale data or leaves the wrong status after the server responds.
employeeId: string, onSeen: (id: string) => Promise<RequestState>, and queryFn: (id: string) => Promise<RequestState>.RequestState has the form:{ id: string; label: string; seen: boolean }
employeeId must clear the screen and must not start a request.employeeId changes, loading must be shown until a response arrives for the current request.Enter is pressed on the “Mark as seen” button, seen must be updated optimistically, and on error only that change must be rolled back.StrictMode in development mode.employeeId = " 15 ", then quickly switch to employeeId = "16" before the first request completes.15, which arrives after the fast response for 16.Enter on the view button and trigger an unsuccessful onSeen response.employeeId, only the data for the current identifier remains on screen.seen, without affecting the current label and id.React.StrictModeUse line comments to explain the problem, its impact, the fix and how to test it.