Skip to content

Instantly share code, notes, and snippets.

View mhmtugur's full-sized avatar
🎯
Focusing

mehmet ugur mhmtugur

🎯
Focusing
  • 22:08 (UTC +02:00)
View GitHub Profile
@mhmtugur
mhmtugur / useFetchWithAbort.tsx
Created August 26, 2022 18:53 — forked from thathurtabit/useFetchWithAbort.tsx
React: Fetch Hook (with AbortController to avoid race conditions and memory leaks)
import { useState, useEffect } from "react";
/* H/T:
Avoiding Race Conditions and Memory Leaks in React useEffect
https://javascript.plainenglish.io/avoiding-race-conditions-and-memory-leaks-in-react-useeffect-2034b8a0a3c7
*/
interface IUseFetchWithAbortResponse {
fetchedData: unknown;
isLoading: boolean;