From 376b561fed0496b80ae9b534c2a659a32f92b1d6 Mon Sep 17 00:00:00 2001 From: Michael Ficocelli Date: Fri, 11 Apr 2025 16:57:42 -0400 Subject: [PATCH] BIGFIX: IPvGO tutorial was getting stuck if you left the tab and returned (#2071) --- src/Go/ui/GoTutorialChallenge.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Go/ui/GoTutorialChallenge.tsx b/src/Go/ui/GoTutorialChallenge.tsx index 0776d6928..08318c8fb 100644 --- a/src/Go/ui/GoTutorialChallenge.tsx +++ b/src/Go/ui/GoTutorialChallenge.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useState } from "react"; +import React, { useRef, useState, useEffect, useCallback } from "react"; import { Typography, Button } from "@mui/material"; import { GoColor, GoValidity, ToastVariant } from "@enums"; @@ -65,12 +65,17 @@ export function GoTutorialChallenge({ } }; - const reset = () => { + const reset = useCallback(() => { stateRef.current = getStateCopy(state); stateRef.current.previousBoards = []; setDisplayText(description); setShowReset(false); - }; + }, [state, description]); + + // Ensure that the challenge is reset on unmount / mount + useEffect(() => { + reset(); + }, [reset]); return (