# Advanced - 10- Fetching Data with Hooks - BUG found

**URL:** <https://forum.codewithmosh.com/t/advanced-10-fetching-data-with-hooks-bug-found/1203>\
**Category:** React\
**Created:** [December 9, 2020, 8:46pm UTC](https://forum.codewithmosh.com/t/advanced-10-fetching-data-with-hooks-bug-found/1203 "2020-12-09T20:46:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hongz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/hongz/32/395_2.png) [@Hongz](https://forum.codewithmosh.com/u/Hongz)\
**Post date:** [December 9, 2020, 8:46pm UTC](https://forum.codewithmosh.com/t/advanced-10-fetching-data-with-hooks-bug-found/1203/1 "2020-12-09T20:46:02Z")

</div>

I noticed there is tiny bug in useEffect function. It should pass an empty array [] argument. Otherwise, it fetches every 20ms.

@Mosh: please update video.

```
  useEffect(() => {
    const getUsers = async () => {
      const result = await axios('https://jsonplaceholder.typicode.com/users');
      setUsers(result.data);
    };

    getUsers();
  }, []);
```

---

<div class="post-metadata">

**Author:** ![Pwnage5](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@Pwnage5](https://forum.codewithmosh.com/u/Pwnage5)\
**Post date:** [March 2, 2021, 8:07pm UTC](https://forum.codewithmosh.com/t/advanced-10-fetching-data-with-hooks-bug-found/1203/2 "2021-03-02T20:07:18Z")

</div>

I was about to post this same issue. I don’t know if it’s because I’m used to Class Components but so far hooks don’t feel right to me.

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [June 29, 2021, 2:08pm UTC](https://forum.codewithmosh.com/t/advanced-10-fetching-data-with-hooks-bug-found/1203/3 "2021-06-29T14:08:37Z")

</div>

Hi.  
Same here.  
When working on context, I noticed some perf issues.  
The network tab showed constant API calls.  
That’s weird because the data itself does not change, so we would assume there is no rerender of the DOM for the data does not change.

Went on StackOverflow because setting the dependency array to users does not help.

[Solution from StackOverflow.](https://stackoverflow.com/questions/53070970/infinite-loop-in-useeffect)

There is an article that explains why this happens even though we put a seemingly proper state property in the dependency array.

[Article on inf loops with useEffect.](https://dmitripavlutin.com/react-useeffect-infinite-loop/)

Kind Regards.
