Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: handle null cases in callback functions #37

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hooks/useLoadData/callbacks/complete/complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export function complete<T>(onSuccess?: (data: T) => void, onError?: (error: unk
return (err?: unknown, res?: T) => {
if (err) {
onError?.(err);
} else if (res) {
} else if (res || res === null) {
NielsJPeschel marked this conversation as resolved.
Show resolved Hide resolved
onSuccess?.(res);
}
};
Expand Down
2 changes: 1 addition & 1 deletion hooks/useLoadData/callbacks/success/success.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function success<T>(onSuccess?: (data: T) => void) {
return (err?: unknown, res?: T) => {
if (res) {
if (res || res === null) {
onSuccess?.(res);
}
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading