Skip to content

Commit

Permalink
refactor(client): remove unnecessary useEffect (freeCodeCamp#57397)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojeytonwilliams authored Dec 4, 2024
1 parent 24abd4d commit e11152d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 52 deletions.
4 changes: 3 additions & 1 deletion client/src/templates/Challenges/codeally/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 0 additions & 17 deletions client/src/templates/Challenges/fill-in-the-blank/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
17 changes: 0 additions & 17 deletions client/src/templates/Challenges/generic/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
17 changes: 0 additions & 17 deletions client/src/templates/Challenges/quiz/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e11152d

Please sign in to comment.