Frontendx
README.md
SOLUTION.md
main.tsxentry
App.tsx
App.css
index.html
vite.config.ts
Installed
react@^19.2.0
react-dom@^19.2.0

Maintain Timer State During Page Navigation — Multi-Page React App with a Timer That Pauses and Resumes Across Routes

Prompt

Build a React app with a Sidenav containing 2–3 page links. Page 1 has a timer that ticks every second. When the user navigates away to another page the timer pauses. When they navigate back to Page 1 the timer resumes from where it left off. The challenge is persisting the timer value across route unmounts — solved using a global state store (Context or Zustand/Redux) or useRef held at a high level so the value survives component unmount/remount. Use react-router for client-side navigation. This was asked for Senior Staff UI Engineer at Palo Alto Networks.

Create a TimerContext that holds {elapsedTime, isRunning} and provides start, pause, resume methods.
Test Results

Maintain Timer State During Page Navigation — Multi-Page React App with a Timer That Pauses and Resumes Across Routes

Build a React app with a Sidenav containing 2–3 page links. Page 1 has a timer that ticks every second. When the user navigates away to another page the timer pauses. When they navigate back to Page 1 the timer resumes from where it left off. The challenge is persisting the timer value across route unmounts — solved using a global state store (Context or Zustand/Redux) or useRef held at a high level so the value survives component unmount/remount. Use react-router for client-side navigation. This was asked for Senior Staff UI Engineer at Palo Alto Networks.