Skip to content

@ghengeveld ghengeveld released this Apr 27, 2019 · 4 commits to master since this release

This separates the <Async.Initial>, <Async.Pending> etc. helper components from <Async> so they can be used with useAsync as well.

import { useAsync, Pending } from "react-async"

function MyComponent() {
  const state = useAsync(...)
  return (
    <Pending state={state}>
      <p>This text is only rendered while performing the initial load.</p>
    </Pending>
  )
}
Assets 2

@ghengeveld ghengeveld released this Apr 27, 2019 · 7 commits to master since this release

This adds two new props/options: reducer and dispatcher. These wrap the internal reducer and dispatcher to allow full control over React Async's internal state management. It also makes invocation of the promiseFn / deferFn part of the dispatched action so it can be delayed, cached or scheduled.

See https://github.com/ghengeveld/react-async/blob/master/README.md#reducer for details.

Assets 2
  • This fixes the type signature for initialValue to allow an Error as initial value.
  • AsyncInitial now specifies initialValue as undefined because you can never have one in the initial state.
Assets 2

@ghengeveld ghengeveld released this Mar 29, 2019 · 21 commits to master since this release

This major release introduces a new status prop which closely follows the terminology in the Promise specification. The Pending helper component was renamed to Initial accordingly, causing a breaking change. The new status prop comes with separate TypeScript types for each state, allowing us to make many optional properties required. This should improve usability in a TypeScript codebase.

  • Breaking change: Async.Pending was renamed to Async.Initial
  • Added the status prop, which can be one of initial, pending, fulfilled or rejected
  • Added isInitial, isPending, isFulfilled (with alias isResolved), isRejected and isSettled boolean props. isLoading is now an alias for isPending.
  • Added separate TypeScript types for each status, to make various props non-optional.

Required upgrade steps:

  • Rename all instances of <Async.Pending> to <Async.Initial>. Don't forget to deal with custom instances of <Async>.

Optional upgrade steps (these are now aliases):

  • Rename isLoading to isPending.
  • Rename <Async.Loading> to <Async.Pending>.
  • Rename <Async.Resolved> to <Async.Fulfilled>.
Assets 2
Mar 27, 2019
6.0.0-0

@ghengeveld ghengeveld released this Mar 21, 2019 · 41 commits to master since this release

  • Better TypeScript support by exporting our own types and interfaces so you won't have to define them again yourself.
  • Replaced custom Fetch API types with the ones from the standard library.
Assets 2

@ghengeveld ghengeveld released this Mar 14, 2019 · 45 commits to master since this release

  • Add indexer for additional props to AsyncOptions type
Assets 2

@ghengeveld ghengeveld released this Mar 9, 2019 · 48 commits to master since this release

  • Added defer and json options to useFetch

This allows you to override the default behavior, which tries to infer the choice automatically.

Assets 2

@ghengeveld ghengeveld released this Mar 3, 2019 · 51 commits to master since this release

This major release changes the way the code is bundled and published by adopting @pika/pack. We now ship separate bundles optimized for browsers and Node.js as well as the original "esnext" source code. package.json now specifies the following:

"esnext": "dist-src/index.js",
"main": "dist-node/index.js",
"module": "dist-web/index.js",
"types": "dist-types/index.d.ts"

This should not break your app, but if it does, please let us know.

New prop: promise

This release also adds a new promise prop, which allows you to pass an already instantiated Promise rather than a function that returns a Promise. This comes with a few limitations:

  • You cannot use reload(), it will do nothing.
  • There's no way to pass props/arguments to the Promise instantiation.
  • The AbortController isn't available either.
Assets 2
You can’t perform that action at this time.