2019-10-03
2407
#react
Raphael Ugwu
7334
Oct 3, 2019 ⋅ 8 min read

Popular React Hook libraries

Raphael Ugwu Writer, software engineer, and a lifelong student.

Recent posts:

Lazy Loading Vs. Eager Loading

Lazy loading vs. Eager loading

In this guide, explore lazy loading and error loading as two techniques for fetching data in React apps.

Njong Emy
Dec 18, 2024 ⋅ 5 min read
Deno logo over an orange background

How to migrate your Node.js app to Deno 2.0

Deno is a popular JavaScript runtime, and it recently launched version 2.0 with several new features, bug fixes, and improvements […]

Yashodhan Joshi
Dec 17, 2024 ⋅ 7 min read
Angular icon over blue background

Generating OpenAPI API clients for Angular

Generate OpenAPI API clients in Angular to speed up frontend development, reduce errors, and ensure consistency with this hands-on guide.

Shalitha Suranga
Dec 16, 2024 ⋅ 9 min read
Implementing Infinite Scroll In React Snap Carousel

Implementing infinite scroll in React with React Snap Carousel

Making carousels can be time-consuming, but it doesn’t have to be. Learn how to use React Snap Carousel to simplify the process.

David Omotayo
Dec 13, 2024 ⋅ 10 min read
View all posts

3 Replies to "Popular React Hook libraries"

  1. Raphael, thanks for your article. I appreciate it!

    One thing that your code example doesn’t touch upon is where to where not to make useFetch calls. I went down a very wrong path by making such calls from event handlers like onClick, onChange, etc. If anyone reading this does the same, try a simple test with your code: Make a call to a given endpoint and then make the same call a second later. In many cases, the second call will not go out because the dependency(s) in the useEffect that makes the ajax call haven’t changed.

    Reading this article, and the comments therein, really helped me: https://blog.logrocket.com/frustrations-with-react-hooks/ Now, the only way I’ll make an ajax call is either: In a useEffect upon loading -or- by setting a local state or context property, which is a dependency of a useEffect and thus forces the code in that useEffect to be executed. The response data will then either populate a local state or context property, which in turn changes the appearance/behavior of a React component element.

    Changing my coding practices with React Hooks in this manner was a definite paradigm switch but one where things now work and there are no longer any “mysterious” bugs.

  2. Hi Robert,

    I’m glad you like my article. Thanks for the positive words.

    Your comment is very insightful, I haven’t tested for edge cases with the useEffect hook but this right here has prompted me to do so. Paul’s article which you recommended was also insightful as well. I will definitely be updating this post and its code demo with my findings.

  3. OMG I sooooo want to save others the wrong path I went down. My little litmus test of calling the same endpoint twice in succession is a super one to avoid the terrible bug I encountered.

    If I can get permission from my employer, I would love to publish the best practices code to use the Context API, useEffect, and calling API Endpoints that I’ve learned over the past few months.

Leave a Reply