Skip to content

Instantly share code, notes, and snippets.

View Armadillidiid's full-sized avatar

Emmanuel Isenah Armadillidiid

View GitHub Profile
@Armadillidiid
Armadillidiid / React useFetch Hook.md
Created February 22, 2025 23:02
A custom React hook for fetching data from an API using the Fetch API and managing loading, error, and abort states.

React useFetch Hook

Preview:
import { useCallback, useEffect, useRef, useState } from "react";

export interface UseFetchOptions extends RequestInit {
  autoInvoke?: boolean;
}

export function useFetch<T>(