fix: useVideo check current before destroying

This commit is contained in:
Timothy Z. 2025-10-30 11:28:51 +02:00
parent 536be36005
commit b876c920fc

View file

@ -152,7 +152,15 @@ const useVideo = () => {
video.current.on('extraSubtitlesTrackLoaded', onExtraSubtitlesTrackLoaded);
video.current.on('extraSubtitlesTrackAdded', onExtraSubtitlesTrackAdded);
return () => video.current.destroy();
return () => {
if (video.current) {
try {
video.current.destroy();
} catch (err) {
console.error('Error destroying video:', err);
}
}
};
}, []);
return {