From 56762d9ae1694b47e16037b696e84f58c692002c Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Tue, 2 Aug 2022 11:53:04 +0300 Subject: [PATCH] PROD-2749 - fix navigation on fcc --- src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx | 7 ++++--- src-ts/tools/learn/free-code-camp/fcc-frame/FccFrame.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx index ac3e422b9..3c1a6f2c7 100644 --- a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx +++ b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx @@ -297,10 +297,11 @@ const FreeCodeCamp: FC<{}> = () => { if (lessonPath !== lessonParam) { setLessonParam(lessonPath) } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ - certificationParam, - lessonParam, - moduleParam, + // DO NOT UPDATE THIS DEPS ARRAY!! + // we do not care about changes to the other deps + // !!only routeParams needs to trigger this effect!! routeParams, ]) diff --git a/src-ts/tools/learn/free-code-camp/fcc-frame/FccFrame.tsx b/src-ts/tools/learn/free-code-camp/fcc-frame/FccFrame.tsx index a497ce808..43127f620 100755 --- a/src-ts/tools/learn/free-code-camp/fcc-frame/FccFrame.tsx +++ b/src-ts/tools/learn/free-code-camp/fcc-frame/FccFrame.tsx @@ -25,6 +25,7 @@ const FccFrame: FC = (props: FccFrameProps) => { const frameRef: MutableRefObject = useRef() const frameIsReady: MutableRefObject = useRef(false) const { onFccLastLessonNavigation, onFccLessonChange, onFccLessonComplete }: FccFrameProps = props + const lessonUrl: string | undefined = props.lesson?.lessonUrl useEffect(() => { if (!frameRef.current || !props.lesson) { @@ -35,12 +36,13 @@ const FccFrame: FC = (props: FccFrameProps) => { Object.assign(frameRef.current, { src: `${EnvironmentConfig.LEARN_SRC}/${props.lesson.lessonUrl}` }) } else { frameRef.current.contentWindow.postMessage(JSON.stringify({ - data: { path: `/${props.lesson.lessonUrl}` }, + data: { path: `/${lessonUrl}` }, event: 'fcc:url:update', }), '*') } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ - props.lesson, + lessonUrl, ]) useEffect(() => {