Skip to content
Open
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
11 changes: 11 additions & 0 deletions .changeset/fix-useCustom-return-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@refinedev/core": patch
---

fix(core): correct useCustom return type to reflect empty object during loading

The `useCustom` hook returns an empty object for `result.data` while loading, but the TypeScript type only indicated it would be `CustomResponse<TData>["data"]`. This caused the type system to not catch potential runtime errors when accessing properties on `result.data` during the loading state.

Updated the return type to `CustomResponse<TData>["data"] | Record<string, never>` to accurately represent that `result.data` can be an empty object while loading.

[Resolves #7088](https://github.com/refinedev/refine/issues/7088)
2 changes: 1 addition & 1 deletion packages/core/src/hooks/data/useCustom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export type UseCustomProps<TQueryFnData, TError, TQuery, TPayload, TData> = {
export type UseCustomReturnType<TData, TError> = {
query: QueryObserverResult<CustomResponse<TData>, TError>;
result: {
data: CustomResponse<TData>["data"];
data: CustomResponse<TData>["data"] | Record<string, never>;
};
} & UseLoadingOvertimeReturnType;

Expand Down