Refactor(Code): Optimize code

This commit is contained in:
2024-10-31 16:03:57 +08:00
parent 51dc1ed377
commit 9d1d5b10d6
2 changed files with 10 additions and 9 deletions

View File

@@ -58,7 +58,9 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
} }
useEffect(() => { useEffect(() => {
if (isLoaded) { if (!isLoaded) {
return
}
iframeRef.current?.contentWindow?.postMessage( iframeRef.current?.contentWindow?.postMessage(
{ {
type: 'UPDATE', type: 'UPDATE',
@@ -66,7 +68,6 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
} as IMessage, } as IMessage,
'*' '*'
) )
}
}, [isLoaded, compiledCode]) }, [isLoaded, compiledCode])
return mobileMode ? ( return mobileMode ? (

View File

@@ -38,7 +38,7 @@ const Simulation = ({ data }: NodeProps<SimulationNode>) => {
ref={data.iframeRef} ref={data.iframeRef}
src={data.iframeUrl} src={data.iframeUrl}
onLoad={() => data.setIsLoaded(true)} onLoad={() => data.setIsLoaded(true)}
sandbox="allow-downloads allow-forms allow-modals allow-scripts" sandbox={'allow-downloads allow-forms allow-modals allow-scripts'}
allow={'clipboard-read; clipboard-write'} allow={'clipboard-read; clipboard-write'}
/> />
</div> </div>