Как избавиться от предупреждения:
Assignments to the 'torrentFile' variable from inside React Hook useEffect will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside useEffect
(На всякий случай перевод: Присваивания переменной torrentFile из React Hook useEffect будут теряться после каждого рендеринга. Чтобы сохранить значение с течением времени, сохраните его в хуке useRef и сохраните изменяемое значение в свойстве .current. В противном случае вы можете переместить эту переменную прямо в useEffect)
Если так вроде и должно быть, что переменная не сохраняет свое значение и при повторном вызове может меняться на другое запрашиваемое значение.
Вот пример кода, один из нескольких, где выводится такое предупреждение
useEffect(() => {
setVideoId(videoId = match.params.videoId)
fetch('/api/...', {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({"videoID": videoId})
});
fetch('/api/...' + videoId)
.then((res) => {console.log(res);
return(res.json())
})
.then((res) => {
setVideoData(videoData= res);
console.log(videoData)
fetch(res.torrentURL)
.then(res => res.blob())
.then(res => {
setTorrentFile(torrentFile= res)
})
fetch('/api/...')
.then((res3) => {
return (res3.json())
})
.then(res3 => {
setUserData(userData= res3, !isFetching);
setIsFetching(false);
})
})
.catch(e => {
console.log(e);
setError(isFetching, error = e );
})