Releases: async-library/react-async
v10.0.1: TypeScript fixes
v10.0.0: Native TypeScript
This is a major release due to the migration to TypeScript. While technically it shouldn't change anything, it might be a breaking change in certain situations. Theres also a bugfix for watchFn and a fix for legacy browsers.
- Migrate to TypeScript [@Khartir and @phryneas in #105]
- Fix stale props being passed to promiseFn when using watchFn [@salolivares in #181]
- Avoid extending built-in JS classes [@ghengeveld in #175]
- Fix generix type declaration [@Khartir in #229]
Thanks to @Avi98, @FredKSchott and @rokoroku for reviewing and helping out.
v10.0.0-alpha.0
v10.0.0-alpha.0
v9.0.0: The one with Suspense support
This release adds basic, experimental support for Suspense. Furthermore it contains mostly bugfixes, one of which causes a minor but breaking change for useFetch.
- Enable experimental support for Suspense by passing the
suspenseflag [@ghengeveld in #153] - Allow overriding fetch's
resourceargument when invokingrunthroughuseFetch[@ghengeveld in #150] - Make sure
useFetchrejects with anErrortype [@artdent in #114] - Fix the
promiserender prop, so it's always a Promise [@ghengeveld in #148] - Add
displayNameto thecreateInstanceTypeScript definition [@artdent in #102] - Fix TypeScript module interop by avoiding synthetic default imports [@rokoroku in #112]
- Remove some TypeScript definitions without implementation [@Khartir in #107]
- Setup new documentation site (https://docs.react-async.com)
Breaking changes
useFetch rejection type
Previously with useFetch, a failure response would reject with the response object. It's better for rejections to be of type Error so that the full stack trace information is available. Also, the TypeScript type definition assumes that the error object is always an instance of Error. Therefore, the rejection value is now of type FetchError (a subclass of Error) which adds the response property so you can still access the underlying response, without breaking contract.
What to do:
- If you are using
useFetchand are using theerrorvalue, expecting it to be of typeResponse, you must now useerror.responseinstead.
Experimental Suspense support
Due to its experimental nature, we may make breaking changes to this feature even in minor or patch releases, until Suspense for data fetching is officially released. Until then, this is marked experimental.
v8.0.0: Renamed helpers, new promise prop, modify useFetch's init
React Async
- Resolved an issue with ambiguous imports, where helpers such as
Fulfilledclash withReact.Fulfilled(#73) - Added
promiserender prop to allow chaining on it (#83) - Better TypeScript definitions for helper components (#72)
- Applied
useCallbackto the returned functions such asrun,cancelandreload(hooks only) (#82) - Allow modification of
useFetch'sinitparam fromrun(#76 by @phryneas) - Improved TypeScript types for
promiseFn/deferFnprops - Introduced codemods for automatic upgrades
- Aligned version numbers for all packages and examples
Breaking change: renamed helpers
All stand-alone helper components are renamed without backwards compatibility. Child components of <Async> are unaffected. To upgrade:
- replace
<Initial>with<IfInitial> - replace
<Pending>with<IfPending> - replace
<Fulfilled>with<IfFulfilled> - replace
<Rejected>with<IfRejected> - replace
<Settled>with<IfSettled>
Note this does not apply to <Async.Initial> and the like.
A codemod is available to automate the upgrade.
Breaking change: run return type
The return type for run was changed from Promise to undefined. You should now use the promise prop instead. This is a manual upgrade. For example:
- const { run } = useAsync(...)
+ const { run, promise } = useAsync(...)
+ useEffect(() => {
+ promise.then(onData, onError)
+ }, [promise])
- const handleClick = () => run(arg).then(onData, onError)
+ const handleClick = () => run(arg)v8.0.0-alpha.0
Pre-release, superseded by v8.0.0.
React Async v7.0.6: Fix stale props on `deferFn` with `useAsync`
This fixes a bug in useAsync where calling run() would invoke deferFn with outdated props. See #69.
React Async v7.0.5: Fixes for React Native and Next.js
- Introduce universal
globalScopeobject needed for DevTools - Fix compatibility with React Native (#65).
- Fix state is undefined issue in Next.js.
- Fix deprecated
urlprop in Next.js. - Add React Native (Expo) example
DevTools v1.0.3
- Use new
globalScopeobject added in v7.0.5
React Async v7.0.4: Correct TypeScript definition for createInstance
- This fixes the type definition for
createInstance(#57)
Special thanks to @ndelangen for help on getting the types right.