refactor(client): remove unnecessary useEffect (#57397)

This commit is contained in:
Oliver Eyton-Williams
2024-12-04 19:30:54 +01:00
committed by GitHub
parent 24abd4d9fc
commit e11152d60b
4 changed files with 3 additions and 52 deletions

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);