From ab5acc423f74e64a0ae875a515953162badc9c95 Mon Sep 17 00:00:00 2001 From: Niels Peschel <52583415+NielsJPeschel@users.noreply.github.com> Date: Tue, 22 Oct 2024 11:00:29 -0400 Subject: [PATCH] Fix: handle null cases in callback functions (#37) * Fix: handle null cases in callback functions * updated version to next --- hooks/useLoadData/callbacks/complete/complete.ts | 2 +- hooks/useLoadData/callbacks/success/success.ts | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/useLoadData/callbacks/complete/complete.ts b/hooks/useLoadData/callbacks/complete/complete.ts index cd3524e..7435730 100644 --- a/hooks/useLoadData/callbacks/complete/complete.ts +++ b/hooks/useLoadData/callbacks/complete/complete.ts @@ -2,7 +2,7 @@ export function complete(onSuccess?: (data: T) => void, onError?: (error: unk return (err?: unknown, res?: T) => { if (err) { onError?.(err); - } else if (res) { + } else if (res || res === null) { onSuccess?.(res); } }; diff --git a/hooks/useLoadData/callbacks/success/success.ts b/hooks/useLoadData/callbacks/success/success.ts index 72aecff..ae4e297 100644 --- a/hooks/useLoadData/callbacks/success/success.ts +++ b/hooks/useLoadData/callbacks/success/success.ts @@ -1,6 +1,6 @@ export function success(onSuccess?: (data: T) => void) { return (err?: unknown, res?: T) => { - if (res) { + if (res || res === null) { onSuccess?.(res); } }; diff --git a/package.json b/package.json index 371629c..f0c8a3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@optum/react-hooks", - "version": "1.0.3", + "version": "1.0.3-next.1", "description": "A reusable set of React hooks", "repository": "https://github.com/Optum/react-hooks", "license": "Apache 2.0",