useAsyncState

Reactive async state. Will not block your setup function and will trigger changes once the promise is ready.

Usage

import axios from 'axios'
import { useAsyncState } from '@ear-monster/use'

const { state, isReady, isLoading } = useAsyncState(
  axios
    .get('https://jsonplaceholder.typicode.com/todos/1')
    .then(t => t.data),
  { id: null },
)