Only scrolling to top when changing videos. Clearing old video when changing videos.

This commit is contained in:
Roland 2022-10-28 08:12:25 -06:00
parent 6854fa3692
commit b163b60837
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 10 additions and 2 deletions

View file

@ -1,4 +1,4 @@
import React, {useState} from 'react';
import React, {useEffect, useState} from 'react';
import {Link, Route, Routes, useParams} from "react-router-dom";
import {
defaultSearchOrder,
@ -22,7 +22,9 @@ import {deleteVideos} from "../api";
export function VideoWrapper() {
const {videoId} = useParams();
const {videoFile, prevFile, nextFile, setFavorite} = useVideo(videoId);
scrollToTop();
// Scroll to the top when videoId changes.
useEffect(scrollToTop, [videoId]);
return <VideoPage videoFile={videoFile} prevFile={prevFile} nextFile={nextFile}
setFavorite={setFavorite} autoplay={true}/>