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), }); }