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.