Trouble using both ref and onIframeAdded
RapidOwl opened this issue · 0 comments
RapidOwl commented
Describe the bug
- ref never seems to get populated.
- onIFrameAdded doesn't seem to get called.
I'm relatively inexperienced with React and this is my first attempt at using ref
so it's entirely possible this is my fault.
To Reproduce
Here's my code extracted for readability:
const videoRef = useRef<HTMLIFrameElement>(null);
useEffect(() => {
if (videoRef.current) {
console.log("videoRef.current is present");
}
}, []);
<LiteYouTubeEmbed
id={post.content.youtubeId}
title={post.content.title}
onIframeAdded={() => console.log("onIframeAdded")}
ref={videoRef}
/>
Expected behavior
I would expect the console to contain logs showing "videoRef.current is present" and "onIframeAdded".
Desktop (please complete the following information):
- OS: Windows
- Browser: Chrome
- Version: 120
Additional context
I'm trying to add react-lite-youtube-embed to a Next.js app (v14). We have a number of event handlers we need to attach to the YouTube iframe and I was expecting to do that inside an effect.