fix(#2246): add clearinterval in useefferct for destroy component

keep-around/fc1872d034b9f93f0ced50cf13012693e4528053
Andrei Dekterev 4 years ago
parent 3c25c7f701
commit fc1872d034
  1. 6
      src/features/MatchPage/hooks/useMatchProfile.tsx

@ -42,15 +42,13 @@ export const useMatchProfile = () => {
}, [sportType, matchId])
useEffect(() => {
let getIntervalMatch
let getIntervalMatch: ReturnType<typeof setInterval>
if (matchProfile?.live && !matchProfile.youtube_link) {
getIntervalMatch = setInterval(
() => getMatchInfo(sportType, matchId).then(setMatchProfile), 1000 * 60 * 3,
)
} else {
return clearInterval(getIntervalMatch)
}
return undefined
return () => clearInterval(getIntervalMatch)
}, [matchProfile, sportType, matchId])
const { events, matchPlaylists } = useMatchData(matchProfile?.live)

Loading…
Cancel
Save