f / f/react-wait

startWaiting with useEffect hook overrides waiters array

Offen
#13 5 Kommentare 5 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
306
Forks
28
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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'.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.