Title
Quiz auto-start effect may use stale startQuiz callback causing inconsistent initialization
Description
The quiz auto-start logic inside QuizClient.tsx uses a useEffect hook that depends on multiple state values but does not include startQuiz in the dependency array.
This can cause React to capture an outdated callback reference, leading to inconsistent auto-start behavior when component state changes.
Location
app/quiz/[slug]/QuizClient.tsx
Current Code
useEffect(() => {
...
}, [autoStart, didAutoStart, isInline, state]);
Expected Behavior
The effect should always use the latest version of startQuiz.
Actual Behavior
The effect may execute with a stale closure and fail to trigger the latest quiz initialization logic.
Impact
- Inconsistent quiz startup behavior
- Potential state synchronization issues
- React Hook dependency warning
Suggested Fix
Add startQuiz to the dependency array or memoize it using useCallback.
Title
Quiz auto-start effect may use stale
startQuizcallback causing inconsistent initializationDescription
The quiz auto-start logic inside
QuizClient.tsxuses auseEffecthook that depends on multiple state values but does not includestartQuizin the dependency array.This can cause React to capture an outdated callback reference, leading to inconsistent auto-start behavior when component state changes.
Location
app/quiz/[slug]/QuizClient.tsxCurrent Code
Expected Behavior
The effect should always use the latest version of
startQuiz.Actual Behavior
The effect may execute with a stale closure and fail to trigger the latest quiz initialization logic.
Impact
Suggested Fix
Add
startQuizto the dependency array or memoize it usinguseCallback.