From e62b05c224dba5231bf0ab082cf0fecff1e1d3df Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 21 Mar 2026 11:38:03 +0100 Subject: [PATCH] fix: prevent React StrictMode double execution in Verify Added hasVerified flag to prevent useEffect from running twice in React 18 StrictMode (development mode). This was causing: 1. First call: 200 OK - verification successful 2. Second call: 400 Bad Request - already verified 3. Error shown to user despite successful verification The fix ensures verify() only runs once per component mount. Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/Verify.jsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/Verify.jsx b/frontend/src/pages/Verify.jsx index df05c7f..5ceef6d 100644 --- a/frontend/src/pages/Verify.jsx +++ b/frontend/src/pages/Verify.jsx @@ -14,15 +14,17 @@ export default function Verify() { const [email, setEmail] = useState('') const [resending, setResending] = useState(false) const [resendSuccess, setResendSuccess] = useState(false) + const [hasVerified, setHasVerified] = useState(false) useEffect(() => { + if (hasVerified) return // Prevent React StrictMode double execution + if (!token) { + setStatus('error') + setError('Kein Verifikations-Token gefunden') + return + } + setHasVerified(true) const verify = async () => { - if (!token) { - setStatus('error') - setError('Kein Verifikations-Token gefunden') - return - } - try { const result = await api.verifyEmail(token)