From 73d2270fe2c29ed59a292a39e83c47d253086315 Mon Sep 17 00:00:00 2001 From: Mikael Brevik Date: Tue, 27 Oct 2020 08:26:27 +0100 Subject: [PATCH] fix(assistant): Fixes possible bug when incorrect data is returned for trip patterns fixes #598 --- src/screens/Assistant/index.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/screens/Assistant/index.tsx b/src/screens/Assistant/index.tsx index fc9363c21e..d7ef205965 100644 --- a/src/screens/Assistant/index.tsx +++ b/src/screens/Assistant/index.tsx @@ -577,12 +577,15 @@ function useTripPatterns( }, ); source.token.throwIfRequested(); - setTripPatterns(response.data); - setSearchState( - response.data.length >= 1 ? 'search-success' : 'search-empty-result', - ); - setTimeOfSearch(searchDate); + if (Array.isArray(response.data)) { + setTripPatterns(response.data); + setSearchState( + response.data.length >= 1 + ? 'search-success' + : 'search-empty-result', + ); + } } catch (e) { if (!isCancel(e)) { setErrorType(getAxiosErrorType(e));