startWaiting with useEffect hook overrides waiters array
- Langage dominant
- JavaScript
- Étoiles
- 306
- Forks
- 28
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hi there!
Thank you for this awesome library.
I experienced a kind of weird behavior while working with this library.
**Description**
if I use method startWaiting in useEffect hook like
```
useEffect(() => {
startWaiting('first');
startWaiting('second');
}, []);
```
**Result**
waiters array contains only 'second' waiter, so waiters array is overwritten.
the same issue would be in the example below:
component1:
```
const Component1 = () => {
useEffect(() => {
const fetchData = async () => {
startWaiting('first');
const response = await apiCall();
endWaiting('first');
}
fetchData();
}, []);
return (/*react markup and Wait component inside*/);
```
component2:
```
const Component2 = () => {
useEffect(() => {
const fetchData = async () => {
startWaiting('second');
const response = await anotherApiCall();
endWaiting('second');
}
fetchData();
}, []);
return (/*react markup and Wait component inside*/);
```
component3:
```
const Component3 = () =>
(
);
```
in this case, every time I am trying to receive waiters array it will contain only 'second'.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Reproduisez le problème en utilisant les deux appels à startWaiting à l’intérieur d’un useEffect, puis comparez le tableau waiters obtenu avec l’exemple séparé de Component1 et Component2. Inspectez les points d’entrée de startWaiting et de l’état des waiters dans le dépôt ; le travail est terminé lorsque les deux waiters, 'first' et 'second', restent disponibles jusqu’à leurs appels endWaiting correspondants.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, react
- Domaine
- frontend
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100