Promise-based React Data Loader – react-async

Category: Featured , Others , React | May 13, 2019
Author: ghengeveld
Views Total: 29
Official Page: Go to website
Last Update: May 13, 2019
License: MIT

React component and hook for declarative promise resolution and data fetching. Leverages the Render Props pattern and Hooks for ultimate flexibility as well as the new Context API for ease of use.

Makes it easy to handle loading and error states, without assumptions about the shape of your data or the type of request.

Features:

  • Zero dependencies
  • Works with promises, async/await and the Fetch API
  • Choose between Render Props, Context-based helper components or the useAsync and useFetch hooks
  • Provides convenient isLoadingstartedAtfinishedAt, et al metadata
  • Provides cancel and reload actions
  • Automatic re-run using watch or watchFn prop
  • Accepts onResolve and onReject callbacks
  • Supports abortable fetch by providing an AbortController
  • Supports optimistic updates using setData
  • Supports server-side rendering through initialValue
  • Comes with type definitions for TypeScript
  • Works well in React Native too!

Installation:

# Yarn
$ yarn add react-async

# NPM
$ npm install react-async --save

Preview: