Replace useEffect with useLayoutEffect in QuizRunner.tsx for currentIndex and showResult updates
This commit is contained in:
@@ -389,7 +389,7 @@ export default function QuizRunner({ defaultMode = 'all', defaultEntryId, autoSt
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (status !== 'running') return;
|
if (status !== 'running') return;
|
||||||
const saved = history[currentIndex];
|
const saved = history[currentIndex];
|
||||||
if (saved) {
|
if (saved) {
|
||||||
@@ -403,7 +403,7 @@ export default function QuizRunner({ defaultMode = 'all', defaultEntryId, autoSt
|
|||||||
}
|
}
|
||||||
}, [currentIndex, history, status]);
|
}, [currentIndex, history, status]);
|
||||||
|
|
||||||
useEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!showResult) return;
|
if (!showResult) return;
|
||||||
setHistory((prev) => {
|
setHistory((prev) => {
|
||||||
const next = [...prev];
|
const next = [...prev];
|
||||||
|
|||||||
Reference in New Issue
Block a user