Edit product


useEffect By Example

You're afraid that adding dependencies to useEffect's dependency array will result in chaos: stale data being displayed by your components, or worse: infinite re-renders. You even wonder if you should leave the code as it is. Telling the product manager that the feature can't be updated isn't as bad as dealing with unwanted effects, is it?

You know that it's possible to write bug-free useEffect code, you just don't think *YOU* can do it.

But what if you could? What if your useEffects ran predictably? What if you knew exactly what the dependency array was for? You could use useEffect with confidence that it does what you expect it to. Imagine!

It's true, using useEffect can be confusing, and easily results in infinite re-renders... but it doesn't have to.

Get the hang of using useEffect like a pro, with useEffect By Example. 

You'll learn how to use useEffect to fetch data, and avoid pesky race conditions. Take the guesswork out of using the dependency array, and prevent infinite re-renders through the use of useCallback and useMemo, while also keeping ESLint happy.

Just block out an afternoon, buy a copy of useEffect By Example, and you'll be using useEffect with the confidence that it does exactly what you need in no time.


About the author

Hey, I'm Max!

I've been building React apps professionally for four years, a professional web developer for the last ten years, and writing code in some form or another since I was 13 years old (I used to write scripts to automate online games).

Outside of business hours I write about React, and provide advice that hopefully helps improve your career at MaxRozen.com.

If you'd like to get in touch with me, email and twitter are your best bets.


Table of Contents

  • Foreword
  • Changelog
  • Requirements
  • Code Examples
  • Chapter 1: Understanding useEffect
  • Chapter 2: Fetching Data
  • Chapter 3: Introducing the dependency array
  • Chapter 4: Preventing Race Conditions with useEffect
  • Chapter 5: useCallback for useEffect
  • Chapter 6: useMemo for useEffect
  • Chapter 7: useState and useEffect
  • Chapter 8: The ESLint Plugin
  • Final Thoughts

Note: As I receive feedback from readers, I may update the book from time to time. The scope of the changes will be described in the Changelog, and you will be notified of any updates.

You've purchased this product

See it in your library

View in Library
Sorry, this item is not available in your location.
Sold out, please go back and pick another option.
-Quantity 1+
  • You'll get: a copy of the eBook in PDF format (both light and dark mode), and full code examples (on CodeSandbox and GitHub)
  • Pages (PDF)47
  • File Size442 KB
  • Chapters8


useEffect By Example

Enter your info to complete your purchase


···· ···· ···· 4242
Test card



Use a different card?


pp paypal

or pay with

We do not keep any of your sensitive credit card information on file with us unless you ask us to after this purchase is complete.

or pay with

You'll be charged US$19.

Your purchase was successful!

We charged your card and sent you a receipt

    Gumroad Library

    Download from the App Store or text yourself a link to the app

    Good news! Since you already have a Gumroad account, it's also been added to your library.

    Powered by Gumroad