From 492ba8a4f95ec1df8d5253b8a91a1cc07864ece1 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 8 Dec 2019 19:35:55 -0700 Subject: [PATCH] Update Changelog --- .size-snapshot.json | 12 ++++++------ CHANGELOG.md | 4 ++++ src/publicUtils.js | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.size-snapshot.json b/.size-snapshot.json index dadcae2..12445f5 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,13 +1,13 @@ { "dist/index.js": { - "bundled": 100428, - "minified": 47447, - "gzipped": 12335 + "bundled": 103166, + "minified": 48591, + "gzipped": 12715 }, "dist/index.es.js": { - "bundled": 99612, - "minified": 46722, - "gzipped": 12189, + "bundled": 102323, + "minified": 47841, + "gzipped": 12565, "treeshaked": { "rollup": { "code": 80, diff --git a/CHANGELOG.md b/CHANGELOG.md index 769b362..4db90a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.0.0-rc.5 + +- Fixed an issue where the exported `useAsyncDebounce` method would crash if its promise throw an error. + ## 7.0.0-rc.4 - A maintenance release, purely intended to update the @latest tag (which was overwritten by a v6 publish) diff --git a/src/publicUtils.js b/src/publicUtils.js index 621e250..82702a7 100644 --- a/src/publicUtils.js +++ b/src/publicUtils.js @@ -133,7 +133,7 @@ export function useMountedLayoutEffect(fn, deps) { }, deps) } -export default function useAsyncDebounce(defaultFn, defaultWait = 0) { +export function useAsyncDebounce(defaultFn, defaultWait = 0) { const debounceRef = React.useRef({}) debounceRef.current.defaultFn = defaultFn debounceRef.current.defaultWait = defaultWait @@ -144,8 +144,9 @@ export default function useAsyncDebounce(defaultFn, defaultWait = 0) { wait = debounceRef.current.defaultWait ) => { if (!debounceRef.current.promise) { - debounceRef.current.promise = new Promise(resolve => { + debounceRef.current.promise = new Promise((resolve, reject) => { debounceRef.current.resolve = resolve + debounceRef.current.reject = reject }) }