console.log('imgRef',imgRef.current.naturalHeight, imgRef.current.naturalWidth)} // print 150 /> video는 onLoad로 못 봅니다. "> console.log('imgRef',imgRef.current.naturalHeight, imgRef.current.naturalWidth)} // print 150 /> video는 onLoad로 못 봅니다. "> console.log('imgRef',imgRef.current.naturalHeight, imgRef.current.naturalWidth)} // print 150 /> video는 onLoad로 못 봅니다. "> const imgRef = useRef<HTMLImageElement>(); const videoRef = useRef<HTMLVideoElement>(); console.log('imgHeight', imgRef.current?.naturalHeight) console.log('imgWidth', imgRef.current?.naturalWidth) console.log('videoHeight',videoRef.current?.videoHeight) console.log('videoWidth',videoRef.current?.videoWidth) return ( <img src="<https://via.placeholder.com/150>" ref={imgRef} onLoad={() => console.log('imgRef',imgRef.current.naturalHeight, imgRef.current.naturalWidth)} // print 150 /> video는 onLoad로 못 봅니다. <video src="<https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4>" ref={videoRef}/> 이미지는 naturalHeight, naturalWidth 비디오는 videoHeight, videoWidth 로 메타 데이터 확인할 수 있습니다. 처음 값은 undefined로 옵니다. video는 onLoad로 metaData 못 봅니다. 비디오는 onloadedmetadata
const imgRef = useRef<HTMLImageElement>(); const videoRef = useRef<HTMLVideoElement>(); console.log('imgHeight', imgRef.current?.naturalHeight) console.log('imgWidth', imgRef.current?.naturalWidth) console.log('videoHeight',videoRef.current?.videoHeight) console.log('videoWidth',videoRef.current?.videoWidth) return ( <img src="<https://via.placeholder.com/150>" ref={imgRef} onLoad={() => console.log('imgRef',imgRef.current.naturalHeight, imgRef.current.naturalWidth)} // print 150 /> video는 onLoad로 못 봅니다. <video src="<https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4>" ref={videoRef}/>
이미지는 naturalHeight, naturalWidth
비디오는 videoHeight, videoWidth 로 메타 데이터 확인할 수 있습니다.
처음 값은 undefined로 옵니다.
video는 onLoad로 metaData 못 봅니다.
비디오는 onloadedmetadata