Next.js Discord

Discord Forum

Question about the video element

Answered
gin posted this in #help-forum
Open in Discord
ginOP
Hey guys, im curious why some attributes exposed by the videoRef are not loading on pageload (metadata).

I have the problem that
videoRef.current
only loads after i play the video.

8 Replies

ginOP
is there any way i can load that in? Because the video itself is already loaded
Are you using that in a useEffect?
@Clown Are you using that in a useEffect?
ginOP
outside of it
in the tsx
@gin outside of it
You'll need to use useEffect. You shouldn't be using ref while rendering.
Answer
(read especially the pitfall section)
ginOP
ty