Skip to content

Commit

Permalink
fixup! fixup! feat: update a way params are thrown to iframe styles
Browse files Browse the repository at this point in the history
  • Loading branch information
niktverd committed Dec 22, 2023
1 parent 4a2744f commit 93526b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/components/Media/Iframe/Iframe.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useEffect, useRef, useState} from 'react';
import React, {useCallback, useEffect, useRef} from 'react';

import {v4 as uuidv4} from 'uuid';

Expand All @@ -17,9 +17,9 @@ const Iframe = (props: MediaComponentIframeProps) => {

const formContainerRef = useRef<HTMLDivElement>(null);
const iframeRef = useRef<HTMLIFrameElement>();
const [iframeId] = useState(uuidv4());
const iframeId = uuidv4();

const updateFormIframe = useCallback(
const updateIframe = useCallback(
(container: HTMLDivElement) => {
if (iframeRef.current) {
iframeRef.current.src = src;
Expand Down Expand Up @@ -81,10 +81,10 @@ const Iframe = (props: MediaComponentIframeProps) => {
const container = formContainerRef.current;

if (container) {
updateFormIframe(container);
updateIframe(container);
window.addEventListener('message', handleMessage, {passive: true});
}
}, [updateFormIframe, handleMessage]);
}, [updateIframe, handleMessage]);

useEffect(() => {
addIframe();
Expand Down
2 changes: 0 additions & 2 deletions src/components/Media/__stories__/Media.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const DefaultTemplate: StoryFn<MediaAllProps> = (args) => (

const IframeTemplate: StoryFn<MediaAllProps> = (args) => (
<div style={{maxWidth: '500px'}}>
<h1>Iframe with margins (default)</h1>
<Media {...args} />
<h1>Iframe without margins</h1>
<Media {...args} margins={false} />
</div>
Expand Down

0 comments on commit 93526b7

Please sign in to comment.