useAsyncStatus()
React Hook
A simple React hook for managing the status of an async action and an associated message
Installation
$ yarn add react-async-status
Usage
status
can be one of:
"none"
– async action not yet initialised"pending"
– async action initialised but not complete"success"
– async action completed successfully"error"
– async action failed
message
is an optional string
setStatus
is a method that takes one of the above statuses, and (optionally) a
message string.
;
Simple example
; ; ;
Alternative example (custom naming)
; ; ;
Development
Testing
The unit test suite can be run with:
$ yarn test
Bundling
The library bundles can be generated with:
$ yarn bundle
Publishing
The package can be published at:
$ yarn publish