Refactor(Code): Optimize code
This commit is contained in:
@@ -58,15 +58,16 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoaded) {
|
||||
iframeRef.current?.contentWindow?.postMessage(
|
||||
{
|
||||
type: 'UPDATE',
|
||||
data: { compiledCode }
|
||||
} as IMessage,
|
||||
'*'
|
||||
)
|
||||
if (!isLoaded) {
|
||||
return
|
||||
}
|
||||
iframeRef.current?.contentWindow?.postMessage(
|
||||
{
|
||||
type: 'UPDATE',
|
||||
data: { compiledCode }
|
||||
} as IMessage,
|
||||
'*'
|
||||
)
|
||||
}, [isLoaded, compiledCode])
|
||||
|
||||
return mobileMode ? (
|
||||
|
||||
@@ -38,7 +38,7 @@ const Simulation = ({ data }: NodeProps<SimulationNode>) => {
|
||||
ref={data.iframeRef}
|
||||
src={data.iframeUrl}
|
||||
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'}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user