Refactor(Code): Optimize code
This commit is contained in:
@@ -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 ? (
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user