From 1d67d55ea8ee8b185734f32cb6c71650d5439860 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Wed, 27 Sep 2023 13:15:04 -0600 Subject: [PATCH] - Updated request to execute 5 times before throwing error --- .../src/components/STTComboBox/STTComboBox.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx b/tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx index a4e2b0de3..826bb80bb 100644 --- a/tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx +++ b/tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react' +import React, { useEffect, useState } from 'react' import PropTypes from 'prop-types' import { useDispatch, useSelector } from 'react-redux' import { fetchSttList } from '../../actions/sttList' @@ -12,15 +12,19 @@ import ComboBox from '../ComboBox' * @param {function} handleBlur - Runs on blur of combo box element. * @param {function} error - Reference to stt errors object. */ + function STTComboBox({ selectStt, selectedStt, handleBlur, error }) { const sttList = useSelector((state) => state?.stts?.sttList) const dispatch = useDispatch() + const [numTries, setNumTries] = useState(0) useEffect(() => { - if (sttList.length === 0) { + if (sttList.length === 0 && numTries < 6) { dispatch(fetchSttList()) + console.log('Num Tries: %d', numTries) + setNumTries(numTries + 1) } - }, [dispatch, sttList]) + }, [dispatch, sttList, numTries]) return (