The project uses React 19.0.0 and TypeScript 5.8.2 and has a small employee presence status widget. It runs in the browser, and the application starts in StrictMode in development mode, so effects are mounted/unmounted repeatedly for verification. Only React DOM is used, with no third-party state libraries.
Function requirements:
employeeId changes, polling the status must run once every 1000 ms;Auto-refresh toggle is turned off, new timers and network requests must stop working;employeeId, the panel must stop requesting the old employee;Last updated text must reflect the time of the last successful response for the current employee.API contract for reproduction:
fetchPresence(employeeId: string): Promise<{ employeeId: string; status: "online" | "offline"; checkedAt: string }>;AbortSignal, so protection must rely on the correct effect lifecycle and up-to-date dependencies.How to reproduce:
employeeId="anna".StrictMode and inspect fetchPresence calls in the console.Auto-refresh and make sure requests keep appearing.employeeId and may show a stale update time.You need to review the changes after the PR and explain the reasons for the unstable behavior. Assume that npm install, then npm run dev starts the app through Vite 6 in the browser, and the code below is already integrated into the project.
React 19.0.0, React DOM 19.0.0, TypeScript 5.8.2, Vite 6.2.0, browser, development mode with React.StrictMode. Assumption: console.log is available in devtools, and the time format is determined by the browser's toLocaleTimeString().
Use line comments to explain the problem, its impact, the fix and how to test it.