Skip to content

Instantly share code, notes, and snippets.

View TheMagicCat's full-sized avatar
🍕
pizza time all the time 🐈‍⬛

TheMagicCat

🍕
pizza time all the time 🐈‍⬛
  • Austin, TX
View GitHub Profile
@TheMagicCat
TheMagicCat / Apps.js
Created November 19, 2020 16:42
useAsync v3
import { useEffect, useCallback } from 'react'
import { useAsync as useAsyncOne } from './useAsyncOne'
import { useAsync as useAsyncTwo } from './useAsyncTwo'
export const AppOne = ({ id = 'zork' }) => {
const { fetcher, cancel } = useCallback(() => apiCall(id), [ id ])
// Signature is: (asyncFn, cancellation, call immediately?)
const { asyncState, data, error, exec } = useAsyncOne(fetcher, cancel, true)