import React , { useEffect } from 'react' ; param { React . RefObject < HTMLVideoElement > } videoRef param { bool } shouldUnloadVideo export default function useUnloadVideo ( videoRef , shouldUnloadVideo ) { useEffect ( ( ) => { if ( shouldUnloadVideo ) { const videoElement = videoRef . current ; videoElement . load ( ) ; } } , [ shouldUnloadVideo , videoRef ] ) ; }