He llamado a la función de actualización de datos cada 4 segundos hasta que la longitud de los registros sea 0.
Dentro de la actualización de datos this.callAPI(); es desencadenar llamada api.
Configuré el tiempo de espera manual durante 4 segundos para llamar a la función a callapi.
En lugar de tiempo de espera, cómo llamar a la API inmediatamente después de que se completó la API anterior.
dataUpdate =()=> { var arrayList = this.arrayList; if(arrayList.length > 0) { var inputData = { ...inputData, data:{ ...inputData.data,first:'',second:'' } }; var first = arrayList[0].first; var second = arrayList[0].second; inputData.data.first = first; inputData.data.second = second; this.setState({ inputData:inputData }); this.callAPI(); arrayList.shift(); this.arrayList = arrayList; if(arrayList.length !== 0){ setTimeout(() => { this.dataUpdate(); }, 4000); } if(arrayList.length === 0){ setTimeout(() => { this.props.callMessage(this.totalCount); }, 1000); } } }Su problema está en tener estado. Haga que la función callapi no tenga estado y pase todos los parámetros necesarios para que pueda llamarla cualquier cantidad de veces y no confíe en la llamada o estado anterior