Skip to content

Instantly share code, notes, and snippets.

View mokadev90's full-sized avatar
🎯
Focusing

mokadev mokadev90

🎯
Focusing
  • MENDOZA, ARGENTINA
  • 21:50 (UTC -03:00)
View GitHub Profile
import { useCallback, useEffect, useState } from "react"
export default function useAsync(callback, dependencies = []) {
const [loading, setLoading] = useState(true)
const [error, setError] = useState()
const [value, setValue] = useState()
const callbackMemoized = useCallback(() => {
setLoading(true)
setError(undefined)