Skip to content
Compare
Choose a tag to compare
  • Export AsyncConstructor [@nealeu in #234]
  • Export Props interfaces to allow exported declarations [@nealeu in #236]
  • Document how to transpile your node_modules with babel to be able to target older browsers [@mbark in #251]
5a7cee9
Compare
Choose a tag to compare

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.

Thanks to @Avi98, @FredKSchott and @rokoroku for reviewing and helping out.

Compare
Choose a tag to compare

v10.0.0-alpha.0

Pre-release
Pre-release
v10.0.0-alpha.0
Compare
Choose a tag to compare

👉 Read the announcement blog post

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 suspense flag [@ghengeveld in #153]
  • Allow overriding fetch's resource argument when invoking run through useFetch [@ghengeveld in #150]
  • Make sure useFetch rejects with an Error type [@artdent in #114]
  • Fix the promise render prop, so it's always a Promise [@ghengeveld in #148]
  • Add displayName to the createInstance TypeScript 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 useFetch and are using the error value, expecting it to be of type Response, you must now use error.response instead.

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.

Compare
Choose a tag to compare

React Async

  • Resolved an issue with ambiguous imports, where helpers such as Fulfilled clash with React.Fulfilled (#73)
  • Added promise render prop to allow chaining on it (#83)
  • Better TypeScript definitions for helper components (#72)
  • Applied useCallback to the returned functions such as run, cancel and reload (hooks only) (#82)
  • Allow modification of useFetch's init param from run (#76 by @phryneas)
  • Improved TypeScript types for promiseFn/deferFn props
  • 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)
Compare
Choose a tag to compare

v8.0.0-alpha.0

Pre-release
Pre-release

Pre-release, superseded by v8.0.0.

Compare
Choose a tag to compare

This fixes a bug in useAsync where calling run() would invoke deferFn with outdated props. See #69.

Compare
Choose a tag to compare
  • Introduce universal globalScope object needed for DevTools
  • Fix compatibility with React Native (#65).
  • Fix state is undefined issue in Next.js.
  • Fix deprecated url prop in Next.js.
  • Add React Native (Expo) example
Compare
Choose a tag to compare
  • Use new globalScope object added in v7.0.5
Compare
Choose a tag to compare
  • This fixes the type definition for createInstance (#57)

Special thanks to @ndelangen for help on getting the types right.