From e11152d60ba6fccf110acd4606ad9db5ceb76d4e Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 4 Dec 2024 19:30:54 +0100 Subject: [PATCH] refactor(client): remove unnecessary useEffect (#57397) --- .../src/templates/Challenges/codeally/show.tsx | 4 +++- .../Challenges/fill-in-the-blank/show.tsx | 17 ----------------- .../src/templates/Challenges/generic/show.tsx | 17 ----------------- client/src/templates/Challenges/quiz/show.tsx | 17 ----------------- 4 files changed, 3 insertions(+), 52 deletions(-) diff --git a/client/src/templates/Challenges/codeally/show.tsx b/client/src/templates/Challenges/codeally/show.tsx index 32561743837..2805b6c492b 100644 --- a/client/src/templates/Challenges/codeally/show.tsx +++ b/client/src/templates/Challenges/codeally/show.tsx @@ -177,7 +177,9 @@ function ShowCodeAlly(props: ShowCodeAllyProps) { }); challengeMounted(challengeMeta.id); container.current?.focus(); - }, [props]); // TODO: split props, so that it doesn't rerender on every prop change + // This effect should be run once on mount + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); const openGitpod = (userToken?: string) => { const { diff --git a/client/src/templates/Challenges/fill-in-the-blank/show.tsx b/client/src/templates/Challenges/fill-in-the-blank/show.tsx index fc2481d8f45..3a96ff0083e 100644 --- a/client/src/templates/Challenges/fill-in-the-blank/show.tsx +++ b/client/src/templates/Challenges/fill-in-the-blank/show.tsx @@ -124,23 +124,6 @@ const ShowFillInTheBlank = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - useEffect(() => { - updateChallengeMeta({ - ...challengeMeta, - title, - challengeType, - helpCategory - }); - challengeMounted(challengeMeta.id); - }, [ - title, - challengeMeta, - challengeType, - helpCategory, - challengeMounted, - updateChallengeMeta - ]); - const handleSubmit = () => { const blankAnswers = fillInTheBlank.blanks.map(b => b.answer); diff --git a/client/src/templates/Challenges/generic/show.tsx b/client/src/templates/Challenges/generic/show.tsx index cf2a664e21c..47426b3d160 100644 --- a/client/src/templates/Challenges/generic/show.tsx +++ b/client/src/templates/Challenges/generic/show.tsx @@ -117,23 +117,6 @@ const ShowGeneric = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - useEffect(() => { - updateChallengeMeta({ - ...challengeMeta, - title, - challengeType, - helpCategory - }); - challengeMounted(challengeMeta.id); - }, [ - title, - challengeMeta, - challengeType, - helpCategory, - challengeMounted, - updateChallengeMeta - ]); - // video const [videoIsLoaded, setVideoIsLoaded] = useState(false); diff --git a/client/src/templates/Challenges/quiz/show.tsx b/client/src/templates/Challenges/quiz/show.tsx index 29d61963c53..cb5298ab01a 100644 --- a/client/src/templates/Challenges/quiz/show.tsx +++ b/client/src/templates/Challenges/quiz/show.tsx @@ -202,23 +202,6 @@ const ShowQuiz = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - useEffect(() => { - updateChallengeMeta({ - ...challengeMeta, - title, - challengeType, - helpCategory - }); - challengeMounted(challengeMeta.id); - }, [ - title, - challengeMeta, - challengeType, - helpCategory, - challengeMounted, - updateChallengeMeta - ]); - const handleFinishQuiz = () => { setShowUnanswered(true);