fix: attendance clock-in silently aborted by broken mountedRef guard
mountedRef was initialized to true but never reset on mount. The cleanup function (useEffect return) set it to false on unmount. In React 18 Strict Mode, components mount-unmount-remount during dev. After the first cleanup, mountedRef stayed false forever. Result: handlePunch set submitting=true, geolocation callbacks fired, but every callback returned early at `if (!mountedRef.current) return` before calling submitPunch. No server request, button stuck. Fix: add `mountedRef.current = true` inside the useEffect body. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -131,6 +131,7 @@ export default function Attendance() {
|
||||
const latestActionRef = useRef<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true;
|
||||
return () => {
|
||||
mountedRef.current = false;
|
||||
if (geoAbortRef.current) geoAbortRef.current.abort();
|
||||
|
||||
Reference in New Issue
Block a user