Skip to content

Commit

Permalink
types: improve type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
gojutin committed Mar 9, 2022
1 parent 7024ccb commit d6893fd
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/react-hook-youtube.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ declare global {
export function useYoutubeIframe(options: YT.PlayerOptions) {
const playerRef = React.useRef<any>();

type YoutubePlayerProps = {
className?: string;
style?: React.CSSProperties;
};

// COMPONENT
const YoutubePlayer = React.useMemo(() => {
return (props: { className?: string; style?: any }) =>
options.videoId ? (
<div
className={props.className || ""}
style={props.style}
id={`youtube-player-${options.videoId}`}
/>
) : null;
return (props: YoutubePlayerProps) => (
<div
className={props.className || ""}
style={props.style}
id={`youtube-player-${options.videoId}`}
/>
);
}, [options.videoId]);

/**
Expand Down Expand Up @@ -295,5 +299,5 @@ export function useYoutubeIframe(options: YT.PlayerOptions) {
getIframe,
destroy,
},
};
} as { YoutubePlayer: React.FC<YoutubePlayerProps>; player: YT.Player };
}

0 comments on commit d6893fd

Please sign in to comment.