Releases: async-library/react-async
v6.1.0: Control state reducer and dispatcher
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.
v6.0.2: Update run/reload methods when dependent props change
v6.0.1: Fix initialValue type signature for TypeScript
- This fixes the type signature for
initialValue
to allow an Error as initial value. AsyncInitial
now specifiesinitialValue
asundefined
because you can never have one in theinitial
state.
v6.0.0: Status prop to match Promise specification
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 toAsync.Initial
- Added the
status
prop, which can be one ofinitial
,pending
,fulfilled
orrejected
- Added
isInitial
,isPending
,isFulfilled
(with aliasisResolved
),isRejected
andisSettled
boolean props.isLoading
is now an alias forisPending
. - 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
toisPending
. - Rename
<Async.Loading>
to<Async.Pending>
. - Rename
<Async.Resolved>
to<Async.Fulfilled>
.
v5.1.2: Export types and interfaces
- 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.
v5.1.1: TypeScript support for additional props
- Add indexer for additional props to AsyncOptions type
v5.1.0: defer and json options for useFetch
- Added
defer
andjson
options touseFetch
This allows you to override the default behavior, which tries to infer the choice automatically.
v5.0.0: Optimized builds and `promise` prop
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.
v4.1.2: Fix invalid arguments order in typings
- Fix invalid arguments order in TypeScript typings.
- Updated Babel setup in preparation of moving to Babel v7.
v4.1.1: Fix broken export
A previous change accidentally broke the default export. This release fixes the bug and tests have been updated to guard against it.