fix: don't double load iframe content

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-09-28 15:40:38 +02:00
parent d5455f7c33
commit 62abd9cbe0
2 changed files with 4 additions and 10 deletions

View file

@ -7,7 +7,7 @@ import { ORIGIN, useBaseUrl } from '../../../../hooks/common/use-base-url'
import { Logger } from '../../../../utils/logger' import { Logger } from '../../../../utils/logger'
import { useEditorToRendererCommunicator } from '../../../editor-page/render-context/editor-to-renderer-communicator-context-provider' import { useEditorToRendererCommunicator } from '../../../editor-page/render-context/editor-to-renderer-communicator-context-provider'
import type { RefObject } from 'react' import type { RefObject } from 'react'
import { useCallback, useEffect, useMemo, useRef } from 'react' import { useCallback, useMemo, useRef } from 'react'
const log = new Logger('IframeLoader') const log = new Logger('IframeLoader')
@ -31,7 +31,7 @@ export const useForceRenderPageUrlOnIframeLoadCallback = (
}, [iframeCommunicator, rendererBaseUrl]) }, [iframeCommunicator, rendererBaseUrl])
const redirectionInProgress = useRef<boolean>(false) const redirectionInProgress = useRef<boolean>(false)
const loadCallback = useCallback(() => { return useCallback(() => {
const frame = iFrameReference.current const frame = iFrameReference.current
if (!frame) { if (!frame) {
@ -50,10 +50,4 @@ export const useForceRenderPageUrlOnIframeLoadCallback = (
frame.src = forcedUrl frame.src = forcedUrl
} }
}, [iFrameReference, onNavigateAway, forcedUrl]) }, [iFrameReference, onNavigateAway, forcedUrl])
useEffect(() => {
loadCallback()
}, [loadCallback])
return loadCallback
} }

View file

@ -78,9 +78,9 @@ export const RendererIframe: React.FC<RendererIframeProps> = ({
useEffect(() => { useEffect(() => {
if (rendererReady) { if (rendererReady) {
log.info('Renderer Ready!') log.debug('Renderer Ready!')
} else { } else {
log.info('Renderer not ready') log.debug('Renderer not ready')
} }
}, [log, rendererReady]) }, [log, rendererReady])