Execute And Watch Async Function In React

Description:

This is a React hook for handling asynchronous tasks, such as backend API calls.

How to use it:

1. Install and import the react-async-watcher.

# Yarn
$ yarn add react-async-watcher
# NPM
$ npm i react-async-watcher
import { useAsyncWatcher } from 'react-async-watcher';

2. Basic usage:

const { execute, reset, status, result, error } = useAsyncWatcher()
execute(async () => {
  // do whatever you want
})

Preview:

Execute And Watch Async Function In React

Add Comment