From 1c8a7a4ecd09bf71c4770ed0fdf78f2dddcf33e9 Mon Sep 17 00:00:00 2001 From: Fernando Maia Date: Mon, 25 Jul 2022 20:59:30 -0300 Subject: [PATCH] Accept undefined in onSuccess/onError --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 05c52c9..6b6e5de 100644 --- a/src/index.ts +++ b/src/index.ts @@ -263,7 +263,7 @@ const useAsyncInternal = ( if (shouldHandlePromise(promise)) { AsyncState.setResult(result); } - normalizedOptions.onSuccess(result, { + normalizedOptions.onSuccess?.(result, { isCurrent: () => CurrentPromise.is(promise), }); }, @@ -271,7 +271,7 @@ const useAsyncInternal = ( if (shouldHandlePromise(promise)) { AsyncState.setError(error); } - normalizedOptions.onError(error, { + normalizedOptions.onError?.(error, { isCurrent: () => CurrentPromise.is(promise), }); }