Skip to content

Releases: async-library/react-async

v4.1.0: PropTypes and debugValue

19 Feb 14:06
Compare
Choose a tag to compare
  • Adds optional PropTypes support, based on whether prop-types is installed (prop-types is an optional dependency).
  • Adds a debug value to useAsync and useFetch for React DevTools.

v4.0.0: Hooks as first-class citizen

13 Feb 10:12
Compare
Choose a tag to compare

React Async

This is a major update making useAsync the primary interface, stabilizing its API. It also adds the useFetch hook for more convenience working with HTTP requests.

import { useFetch } from "react-async"

const MyComponent = () => {
  const headers = { Accept: "application/json" }
  const { data, error, isLoading } = useFetch("/api/example", { headers })
  // This will setup a promiseFn with a fetch request and JSON deserialization.
}

Furthermore there's several breaking changes:

  • deferFn now receives an args array as the first argument, instead of arguments to run being spread at the front of the arguments list. This enables better interop with TypeScript. You can use destructuring to keep using your existing variables.
  • The shorthand version of useAsync now takes the options object as optional second argument. This used to be initialValue, but was undocumented and inflexible.

v3.13.4: Fix onReject handler name in typings

12 Feb 12:41
Compare
Choose a tag to compare
  • Fix onReject handler in typings.

v3.13.3: Fix "Uncaught TypeError: Illegal invocation" (#20)

12 Feb 12:24
Compare
Choose a tag to compare
  • Fix #20: TypeError caused by calling abortController.abort() with invalid context.

v3.13.2: Deprecate undocumented useAsync shorthand

12 Feb 12:16
Compare
Choose a tag to compare
  • Add deprecation notice for undocumented useAsync(promiseFn, initialValue) shorthand.

v3.13.1: Fix watchFn with default props

04 Feb 14:56
Compare
Choose a tag to compare
  • Accepts watchFn from defaultProps when using createInstance.
  • Passes defaultProps to watchFn.

v3.13.0: Flexible automatic reloading with watchFn

04 Feb 13:47
Compare
Choose a tag to compare
  • Add 'watchFn' for more flexibility in reloading based on prop changes.
  • Fix AsyncProps type (#19)

v3.12.1: Fix passing defaultProps to deferFn

21 Jan 11:45
Compare
Choose a tag to compare

When using createInstance with preconfigured props, deferFn now receives these defaultProps along with any other props.

v3.12.0: Abortable fetch using AbortController

02 Jan 20:14
Compare
Choose a tag to compare

React Async now automatically instantiates an AbortController with each promise. The controller is passed to the promiseFn and/or deferFn. Its signal property can be passed as an option to fetch. Whenever a promise is canceled, the signal is aborted, canceling the underlying HTTP request.

v3.11.0: useAsync

30 Dec 22:19
Compare
Choose a tag to compare

It's finally here: the useAsync hook. This adds a very promising new way to use React Async, without the need for wrapper components. An important milestone.

useAsync is a React hook that makes working with Promises a breeze. It provides metadata such as isLoading and startedAt and deals with race conditions and promise cancellation.

A working usage example is provided here: https://github.com/ghengeveld/react-async/tree/master/examples/basic-hook

dqq6omfxgaeosim