Skip to content

Commit

Permalink
- Updated request to execute 5 times before throwing error
Browse files Browse the repository at this point in the history
  • Loading branch information
elipe17 committed Sep 27, 2023
1 parent 43cb33d commit 1d67d55
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tdrs-frontend/src/components/STTComboBox/STTComboBox.jsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 (
<ComboBox
Expand Down

0 comments on commit 1d67d55

Please sign in to comment.