From 786a11281b74e0e8d073155e7b8d4efd07ff3d02 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Wed, 26 Apr 2023 19:11:07 +0700 Subject: [PATCH] fix(#560): check matchProfile in matchPage --- src/features/MatchPage/store/hooks/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/features/MatchPage/store/hooks/index.tsx b/src/features/MatchPage/store/hooks/index.tsx index d4438600..f748a7c2 100644 --- a/src/features/MatchPage/store/hooks/index.tsx +++ b/src/features/MatchPage/store/hooks/index.tsx @@ -175,7 +175,12 @@ export const useMatchPage = () => { ]) useEffect(() => { - getMatchInfo(sportType, matchId).then(setMatchProfile) + getMatchInfo(sportType, matchId).then( + (info) => (info?.sport + // проверяем именно какой-то ключ в объекте, + // потому что, когда матча не существует, приходит - [] + ? setMatchProfile(info) : window.location.replace(PAGES.home)), + ) }, [sportType, matchId]) useEffect(() => {