Skip to content

Commit

Permalink
Cast mediaRef types
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Sep 8, 2022
1 parent d354a6a commit f709d34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions packages/components/src/focal-point-picker/media.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import type { Ref } from 'react';

/**
* Internal dependencies
*/
Expand All @@ -20,7 +25,7 @@ export default function Media( {
return (
<MediaPlaceholder
className="components-focal-point-picker__media components-focal-point-picker__media--placeholder"
ref={ mediaRef }
ref={ mediaRef as Ref< HTMLDivElement > }
{ ...props }
/>
);
Expand All @@ -36,7 +41,7 @@ export default function Media( {
loop
muted={ muted }
onLoadedData={ onLoad }
ref={ mediaRef }
ref={ mediaRef as Ref< HTMLVideoElement > }
src={ src }
/>
) : (
Expand All @@ -45,7 +50,7 @@ export default function Media( {
alt={ alt }
className="components-focal-point-picker__media components-focal-point-picker__media--image"
onLoad={ onLoad }
ref={ mediaRef }
ref={ mediaRef as Ref< HTMLImageElement > }
src={ src }
/>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/focal-point-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export type FocalPointPickerMediaProps = Pick<
'autoPlay' | 'muted'
> & {
alt: string;
mediaRef?: Ref< any >;
mediaRef?: Ref< HTMLDivElement | HTMLVideoElement | HTMLImageElement >;
onLoad?: ReactEventHandler< HTMLVideoElement | HTMLImageElement >;
src: string;
};
Expand Down

0 comments on commit f709d34

Please sign in to comment.